-
Notifications
You must be signed in to change notification settings - Fork 85
/
alreadyexists.go
63 lines (53 loc) · 1.26 KB
/
alreadyexists.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
59
60
61
62
63
package bacerrors
import (
"fmt"
)
type AlreadyExists GenericError
func NewAlreadyExists(id string, typ string) *AlreadyExists {
var e AlreadyExists
e.Code = ErrorCodeAlreadyExists
e.Message = fmt.Sprintf(ErrorMessageAlreadyExists, id, typ)
e.Details = make(map[string]interface{})
e.Details["id"] = id
e.SetID(id)
e.SetError(fmt.Errorf("%s", e.Message))
return &e
}
func (e *AlreadyExists) GetMessage() string {
return e.Message
}
func (e *AlreadyExists) SetMessage(s string) {
e.Message = s
}
func (e *AlreadyExists) Error() string {
return e.GetError().Error()
}
func (e *AlreadyExists) GetError() error {
return e.Err
}
func (e *AlreadyExists) SetError(err error) {
e.Err = err
}
func (e *AlreadyExists) GetCode() string {
return ErrorCodeJobNotFound
}
func (e *AlreadyExists) SetCode(string) {
e.Code = ErrorCodeJobNotFound
}
func (e *AlreadyExists) GetDetails() map[string]interface{} {
return e.Details
}
func (e *AlreadyExists) GetID() string {
if id, ok := e.Details["id"]; ok {
return id.(string)
}
return ""
}
func (e *AlreadyExists) SetID(s string) {
e.Details["id"] = s
}
const (
ErrorCodeAlreadyExists = "error-already-exists"
ErrorMessageAlreadyExists = "%s (%s) already exists."
)
var _ BacalhauErrorInterface = (*AlreadyExists)(nil)