-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherrors.go
More file actions
38 lines (31 loc) · 845 Bytes
/
errors.go
File metadata and controls
38 lines (31 loc) · 845 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
package gqlstruct
import (
"fmt"
"reflect"
)
type typeNotRecognizedError struct {
t reflect.Type
}
func (err *typeNotRecognizedError) Error() string {
return fmt.Sprintf("'%s' not recognized", err.t)
}
func NewErrTypeNotRecognized(t reflect.Type) error {
return &typeNotRecognizedError{
t: t,
}
}
type TypeNotRecognizedWithStructError struct {
reason error
structType reflect.Type
fieldStruct reflect.StructField
}
func (err *TypeNotRecognizedWithStructError) Error() string {
return fmt.Sprintf("%s.%s:%s", err.structType.Name(), err.fieldStruct.Name, err.reason.Error())
}
func NewErrTypeNotRecognizedWithStruct(reason error, structType reflect.Type, structField reflect.StructField) error {
return &TypeNotRecognizedWithStructError{
reason: reason,
structType: structType,
fieldStruct: structField,
}
}