-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pre_execute_error.go
57 lines (46 loc) · 1020 Bytes
/
pre_execute_error.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package hype
import (
"encoding/json"
"errors"
)
type PreExecuteError struct {
Err error
Document *Document
Filename string
Root string
PreExecuter any
}
func (pee PreExecuteError) MarshalJSON() ([]byte, error) {
mm := map[string]any{
"document": pee.Document,
"error": errForJSON(pee.Err),
"filename": pee.Filename,
"pre_executer": toType(pee.PreExecuter),
"root": pee.Root,
"type": toType(pee),
}
return json.MarshalIndent(mm, "", " ")
}
func (pee PreExecuteError) Error() string {
return toError(pee)
}
func (pee PreExecuteError) Unwrap() error {
if _, ok := pee.Err.(unwrapper); ok {
return errors.Unwrap(pee.Err)
}
return pee.Err
}
func (pee PreExecuteError) As(target any) bool {
ex, ok := target.(*PreExecuteError)
if !ok {
return false
}
(*ex) = pee
return true
}
func (pee PreExecuteError) Is(target error) bool {
if _, ok := target.(PreExecuteError); ok {
return true
}
return errors.Is(pee.Err, target)
}