forked from italia/publiccode-parser-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
40 lines (32 loc) · 896 Bytes
/
Copy patherrors.go
File metadata and controls
40 lines (32 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package publiccode
import (
"fmt"
"strings"
)
// ErrorInvalidKey represents an error caused by an invalid key.
type ErrorInvalidKey struct {
Key string
}
func (e ErrorInvalidKey) Error() string {
return fmt.Sprintf("invalid key: %s", e.Key)
}
// ErrorInvalidValue represents an error caused by an invalid value.
type ErrorInvalidValue struct {
Key string
Reason string
}
func (e ErrorInvalidValue) Error() string {
return fmt.Sprintf("%s: %s", e.Key, e.Reason)
}
func newErrorInvalidValue(key string, reason string, args ...interface{}) ErrorInvalidValue {
return ErrorInvalidValue{Key: key, Reason: fmt.Sprintf(reason, args...)}
}
// ErrorParseMulti represents an error caused by a multivalue key.
type ErrorParseMulti []error
func (es ErrorParseMulti) Error() string {
var ss []string
for _, e := range es {
ss = append(ss, e.Error())
}
return strings.Join(ss, "\n")
}