-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
41 lines (34 loc) · 697 Bytes
/
errors.go
File metadata and controls
41 lines (34 loc) · 697 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
package types
type ErrorCode int
const (
ErrorCodeUnknown ErrorCode = iota
ErrorCodeNameRequired
ErrorCodeNameNotFound
ErrorCodeStoreFailure
ErrorCodeRoutingNotFound
)
type DomainError struct {
Code ErrorCode
Message string
Cause error
}
func (e DomainError) Error() string {
if e.Cause != nil {
return e.Message + ": " + e.Cause.Error()
}
return e.Message
}
var (
ErrNameRequired = DomainError{
Code: ErrorCodeNameRequired,
Message: "name is required",
}
ErrNameNotFound = DomainError{
Code: ErrorCodeNameNotFound,
Message: "name not found",
}
ErrRoutingNotFound = DomainError{
Code: ErrorCodeRoutingNotFound,
Message: "routing not found",
}
)