-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
40 lines (33 loc) · 848 Bytes
/
errors.go
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 gomap
import (
"fmt"
"strings"
)
//WrongPathError raised when the path is not correct
type WrongPathError struct {
path []string
}
func (e *WrongPathError) Error() string {
return fmt.Sprintf("Wrong path %s", strings.Join(e.path, "/"))
}
//NewWrongPathError creates a new WrongPathError
func NewWrongPathError(path []string) *WrongPathError {
return &WrongPathError{
path: path,
}
}
//WrongTypeError raised when the path is not correct
type WrongTypeError struct {
expected string
value interface{}
}
func (e *WrongTypeError) Error() string {
return fmt.Sprintf("Wrong type: expected %s actual %T", e.expected, e.value)
}
//NewWrongTypeError creates a new WrongPathError
func NewWrongTypeError(expected string, value interface{}) *WrongTypeError {
return &WrongTypeError{
expected: expected,
value: value,
}
}