-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
44 lines (36 loc) · 954 Bytes
/
errors.go
File metadata and controls
44 lines (36 loc) · 954 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
39
40
41
42
43
44
package workable
import "fmt"
///////////////////////////////////////////////////////////////////////////////
// TYPES
type Error uint
///////////////////////////////////////////////////////////////////////////////
// GLOBALS
const (
ErrSuccess Error = iota
ErrBadParameter
ErrUnexpectedResponse
ErrInternalAppError
ErrNotFound
)
///////////////////////////////////////////////////////////////////////////////
// STRINGIFY
func (e Error) Error() string {
switch e {
case ErrSuccess:
return "ErrSuccess"
case ErrBadParameter:
return "ErrBadParameter"
case ErrUnexpectedResponse:
return "ErrUnexpectedResponse"
case ErrInternalAppError:
return "ErrInternalAppError"
case ErrNotFound:
return "ErrNotFound"
default:
return "[?? Invalid Error value]"
}
}
// With appends any additional arguments onto an error for context
func (e Error) With(args ...interface{}) error {
return fmt.Errorf("%w: %v", e, fmt.Sprint(args...))
}