-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherrors.go
More file actions
28 lines (22 loc) · 763 Bytes
/
errors.go
File metadata and controls
28 lines (22 loc) · 763 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
package jsonpath
import (
goErr "errors"
"fmt"
"github.com/evilmonkeyinc/jsonpath/errors"
)
var (
errDataIsUnexpectedTypeOrNil error = fmt.Errorf("unexpected type or nil")
errOptionAlreadySet error = fmt.Errorf("option already set")
)
func getInvalidJSONData(reason error) error {
return fmt.Errorf("%w. %s", errors.ErrInvalidJSONData, reason.Error())
}
func getInvalidJSONPathSelector(selector string) error {
return fmt.Errorf("%w '%s'", errors.ErrInvalidJSONPathSelector, selector)
}
func getInvalidJSONPathSelectorWithReason(selector string, reason error) error {
if goErr.Is(reason, errors.ErrInvalidJSONPathSelector) {
return reason
}
return fmt.Errorf("%w '%s' %s", errors.ErrInvalidJSONPathSelector, selector, reason.Error())
}