-
Notifications
You must be signed in to change notification settings - Fork 0
/
err.go
55 lines (43 loc) · 810 Bytes
/
err.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
package err
import "runtime"
type Err struct {
previous error
message string
code int
statusCode int
isWebErr bool
file string
line int
}
func (e *Err) Error() string {
return e.message
}
func (e *Err) setPrevious(err error) {
e.previous = err
}
func (e *Err) Previous() error {
return e.previous
}
func (e *Err) Message() string {
return e.message
}
func (e *Err) Code() int {
return e.code
}
func (e *Err) StatusCode() int {
return e.statusCode
}
func (e *Err) IsWebErr() bool {
return e.isWebErr
}
func (e *Err) SetLocation() {
e.SetRawLocation(1)
}
func (e *Err) SetRawLocation(callDepth int) {
_, file, line, _ := runtime.Caller(callDepth + 1)
e.file = file
e.line = line
}
func (e *Err) Location() (file string, line int) {
return e.file, e.line
}