-
Notifications
You must be signed in to change notification settings - Fork 85
/
multiplejobsfound.go
57 lines (47 loc) · 1.33 KB
/
multiplejobsfound.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
package bacerrors
import (
"fmt"
)
type MultipleJobsFound GenericError
func NewMultipleJobsFound(id string, matchingJobIDs []string) *MultipleJobsFound {
var e MultipleJobsFound
if len(matchingJobIDs) > 3 {
matchingJobIDs = append(matchingJobIDs[:3], "...")
}
e.Code = ErrorCodeMultipleJobsFound
e.Message = fmt.Sprintf(ErrorMessageMultipleJobsFound, id, matchingJobIDs)
e.Details = make(map[string]interface{})
e.Details["id"] = id
e.Details["matchingJobIDs"] = matchingJobIDs
e.SetError(fmt.Errorf("%s", e.Message))
return &e
}
func (e *MultipleJobsFound) GetMessage() string {
return e.Message
}
func (e *MultipleJobsFound) SetMessage(s string) {
e.Message = s
}
func (e *MultipleJobsFound) Error() string {
return e.GetError().Error()
}
func (e *MultipleJobsFound) GetError() error {
return e.Err
}
func (e *MultipleJobsFound) SetError(err error) {
e.Err = err
}
func (e *MultipleJobsFound) GetCode() string {
return ErrorCodeMultipleJobsFound
}
func (e *MultipleJobsFound) SetCode(string) {
e.Code = ErrorCodeMultipleJobsFound
}
func (e *MultipleJobsFound) GetDetails() map[string]interface{} {
return e.Details
}
const (
ErrorCodeMultipleJobsFound = "ambiguous-job-id"
ErrorMessageMultipleJobsFound = "Multiple jobs found for jobID prefix: %s, matching jobIDs: %v"
)
var _ BacalhauErrorInterface = (*MultipleJobsFound)(nil)