-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
47 lines (37 loc) · 974 Bytes
/
errors.go
File metadata and controls
47 lines (37 loc) · 974 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
41
42
43
44
45
46
47
package gofieldselect
import (
"errors"
"fmt"
"reflect"
"strings"
)
var (
_ error = new(ParsingError)
ErrExpectedIdentifier = errors.New("expected identifier")
ErrMissingSeparatorBetweenIdentifiers = errors.New("missing separator between identifiers")
ErrExpectedClosingParenthesis = errors.New("expected closing parenthesis")
)
type (
ParsingError struct {
errSlice []error
}
TypeNotValidError struct {
kind reflect.Kind
}
)
func NewParsingError(errSlice []error) ParsingError {
return ParsingError{errSlice: errSlice}
}
func (pe ParsingError) Error() string {
ss := make([]string, len(pe.errSlice))
for i, e := range pe.errSlice {
ss[i] = e.Error()
}
return strings.Join(ss, ",")
}
func NewTypeNotValidError(kind reflect.Kind) TypeNotValidError {
return TypeNotValidError{kind: kind}
}
func (e TypeNotValidError) Error() string {
return fmt.Sprintf("Kind must be a struct or pointer to struct, got %q", e.kind)
}