diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2021-07-17 17:29:31 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-07-17 17:29:31 +0900 |
commit | 2c22c1e193ce8b3abd6f1436457ff92a40646e45 (patch) | |
tree | 2979b4d644e038ae2ec84a201c2557d3db5e1570 /error/error.go | |
parent | Improve syntax error messages (diff) | |
download | urubu-2c22c1e193ce8b3abd6f1436457ff92a40646e45.tar.gz urubu-2c22c1e193ce8b3abd6f1436457ff92a40646e45.tar.xz |
Detect multiple syntax errors in a single parse
Diffstat (limited to 'error/error.go')
-rw-r--r-- | error/error.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/error/error.go b/error/error.go index cc4fed5..1e5df7a 100644 --- a/error/error.go +++ b/error/error.go @@ -7,6 +7,22 @@ import ( "strings" ) +type SpecErrors []*SpecError + +func (e SpecErrors) Error() string { + if len(e) == 0 { + return "" + } + + var b strings.Builder + fmt.Fprintf(&b, "%v", e[0]) + for _, err := range e[1:] { + fmt.Fprintf(&b, "\n%v", err) + } + + return b.String() +} + type SpecError struct { Cause error FilePath string |