-
Notifications
You must be signed in to change notification settings - Fork 14
/
error.go
58 lines (50 loc) · 1.16 KB
/
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
58
package gopi
import "fmt"
///////////////////////////////////////////////////////////////////////////////
// Types
type Error uint
///////////////////////////////////////////////////////////////////////////////
// Globals
const (
ErrNone Error = iota
ErrBadParameter
ErrNotImplemented
ErrNotFound
ErrUnexpectedResponse
ErrHelp
ErrInternalAppError
ErrDuplicateEntry
ErrOutOfOrder
ErrChannelFull
)
///////////////////////////////////////////////////////////////////////////////
// Implementation
func (e Error) Error() string {
switch e {
case ErrNone:
return "No Error"
case ErrBadParameter:
return "Bad Parameter"
case ErrNotImplemented:
return "Not Implemented"
case ErrNotFound:
return "Not Found"
case ErrHelp:
return "Help Requested"
case ErrUnexpectedResponse:
return "Unexpected Response"
case ErrInternalAppError:
return "Internal Application Error"
case ErrDuplicateEntry:
return "Duplicate Entry"
case ErrOutOfOrder:
return "Out of Order"
case ErrChannelFull:
return "Channel Full"
default:
return "[?? Invalid Error]"
}
}
func (e Error) WithPrefix(p ...interface{}) error {
return fmt.Errorf("%v: %w", fmt.Sprint(p...), e)
}