aboutsummaryrefslogtreecommitdiff
path: root/error/error.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2021-07-17 17:29:31 +0900
committerRyo Nihei <nihei.dev@gmail.com>2021-07-17 17:29:31 +0900
commit2c22c1e193ce8b3abd6f1436457ff92a40646e45 (patch)
tree2979b4d644e038ae2ec84a201c2557d3db5e1570 /error/error.go
parentImprove syntax error messages (diff)
downloadcotia-2c22c1e193ce8b3abd6f1436457ff92a40646e45.tar.gz
cotia-2c22c1e193ce8b3abd6f1436457ff92a40646e45.tar.xz
Detect multiple syntax errors in a single parse
Diffstat (limited to 'error/error.go')
-rw-r--r--error/error.go16
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