forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task_errors.go
133 lines (114 loc) · 3.23 KB
/
task_errors.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package influxdb
import (
"fmt"
"time"
)
var (
// ErrRunCanceled is returned from the RunResult when a Run is Canceled. It is used mostly internally.
ErrRunCanceled = &Error{
Code: EInternal,
Msg: "run canceled",
}
// ErrTaskNotClaimed is returned when attempting to operate against a task that must be claimed but is not.
ErrTaskNotClaimed = &Error{
Code: EConflict,
Msg: "task not claimed",
}
// ErrTaskAlreadyClaimed is returned when attempting to operate against a task that must not be claimed but is.
ErrTaskAlreadyClaimed = &Error{
Code: EConflict,
Msg: "task already claimed",
}
// ErrNoRunsFound is returned when searching for a range of runs, but none are found.
ErrNoRunsFound = &Error{
Code: ENotFound,
Msg: "no matching runs found",
}
// ErrInvalidTaskID error object for bad id's
ErrInvalidTaskID = &Error{
Code: EInvalid,
Msg: "invalid id",
}
// ErrInvalidTaskType error object for bad id's
ErrInvalidTaskType = &Error{
Code: EInvalid,
Msg: "invalid task type",
}
// ErrTaskNotFound indicates no task could be found for given parameters.
ErrTaskNotFound = &Error{
Code: ENotFound,
Msg: "task not found",
}
// ErrRunNotFound is returned when searching for a single run that doesn't exist.
ErrRunNotFound = &Error{
Code: ENotFound,
Msg: "run not found",
}
ErrPageSizeTooSmall = &Error{
Msg: "cannot have negative page limit",
Code: EInvalid,
}
ErrPageSizeTooLarge = &Error{
Msg: fmt.Sprintf("cannot use page size larger then %d", MaxPageSize),
Code: EInvalid,
}
ErrOrgNotFound = &Error{
Msg: "organization not found",
Code: ENotFound,
}
ErrTaskRunAlreadyQueued = &Error{
Msg: "run already queued",
Code: EConflict,
}
// ErrOutOfBoundsLimit is returned with FindRuns is called with an invalid filter limit.
ErrOutOfBoundsLimit = &Error{
Code: EUnprocessableEntity,
Msg: "run limit is out of bounds, must be between 1 and 500",
}
// ErrInvalidOwnerID is called when trying to create a task with out a valid ownerID
ErrInvalidOwnerID = &Error{
Code: EInvalid,
Msg: "cannot create task with invalid ownerID",
}
)
func ErrInternalTaskServiceError(err error) *Error {
return &Error{
Code: EInternal,
Msg: fmt.Sprintf("unexpected error in tasks; Err: %v", err),
Op: "kv/task",
Err: err,
}
}
// ErrUnexpectedTaskBucketErr a generic error we can use when we rail to retrieve a bucket
func ErrUnexpectedTaskBucketErr(err error) *Error {
return &Error{
Code: EInternal,
Msg: fmt.Sprintf("unexpected error retrieving task bucket; Err: %v", err),
Op: "kv/taskBucket",
Err: err,
}
}
// ErrTaskTimeParse an error for time parsing errors
func ErrTaskTimeParse(err error) *Error {
return &Error{
Code: EInvalid,
Msg: fmt.Sprintf("unexpected error parsing time; Err: %v", err),
Op: "kv/taskCron",
Err: err,
}
}
func ErrTaskOptionParse(err error) *Error {
return &Error{
Code: EInvalid,
Msg: fmt.Sprintf("invalid options; Err: %v", err),
Op: "kv/taskOptions",
Err: err,
}
}
// ErrRunNotDueYet is returned from CreateNextRun if a run is not yet due.
func ErrRunNotDueYet(dueAt int64) *Error {
return &Error{
Code: EInvalid,
Msg: fmt.Sprintf("run not due until: %v", time.Unix(dueAt, 0).UTC().Format(time.RFC3339)),
}
}