-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathtask_errors.go
189 lines (163 loc) · 4.6 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
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",
}
// 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",
}
ErrRunKeyNotFound = &Error{
Code: ENotFound,
Msg: "run key 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",
}
)
// ErrFluxParseError is returned when an error is thrown by Flux.Parse in the task executor
func ErrFluxParseError(err error) *Error {
return &Error{
Code: EInvalid,
Msg: fmt.Sprintf("could not parse Flux script; Err: %v", err),
Op: "taskExecutor",
Err: err,
}
}
// ErrQueryError is returned when an error is thrown by Query service in the task executor
func ErrQueryError(err error) *Error {
return &Error{
Code: EInternal,
Msg: fmt.Sprintf("unexpected error from queryd; Err: %v", err),
Op: "taskExecutor",
Err: err,
}
}
// ErrResultIteratorError is returned when an error is thrown by exhaustResultIterators in the executor
func ErrResultIteratorError(err error) *Error {
return &Error{
Code: EInvalid,
Msg: fmt.Sprintf("Error exhausting result iterator; Err: %v", err),
Op: "taskExecutor",
Err: err,
}
}
func ErrInternalTaskServiceError(err error) *Error {
return &Error{
Code: EInternal,
Msg: fmt.Sprintf("unexpected error in tasks; Err: %v", err),
Op: "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: "taskBucket",
Err: err,
}
}
// ErrTaskTimeParse an error for time parsing errors
func ErrTaskTimeParse(err error) *Error {
return &Error{
Code: EInternal,
Msg: fmt.Sprintf("unexpected error parsing time; Err: %v", err),
Op: "taskCron",
Err: err,
}
}
func ErrTaskOptionParse(err error) *Error {
return &Error{
Code: EInvalid,
Msg: fmt.Sprintf("invalid options; Err: %v", err),
Op: "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)),
}
}
func ErrJsonMarshalError(err error) *Error {
return &Error{
Code: EInvalid,
Msg: fmt.Sprintf("unable to marshal JSON; Err: %v", err),
Op: "taskScheduler",
Err: err,
}
}
func ErrRunExecutionError(err error) *Error {
return &Error{
Code: EInternal,
Msg: fmt.Sprintf("could not execute task run; Err: %v", err),
Op: "taskExecutor",
Err: err,
}
}
func ErrTaskConcurrencyLimitReached(runsInFront int) *Error {
return &Error{
Code: ETooManyRequests,
Msg: fmt.Sprintf("could not execute task, concurrency limit reached, runs in front: %d", runsInFront),
Op: "taskExecutor",
}
}