pub enum TaskError {
ExpectedError(String),
UnexpectedError(String),
TimeoutError,
Retry(Option<DateTime<Utc>>),
}
Expand description
Errors that can occur at the task level.
Variants§
ExpectedError(String)
An error that is expected to happen every once in a while.
These errors will only be logged at the WARN
level and will always trigger a task
retry unless max_retries
is set to 0 (or max retries is exceeded).
A typical example is a task that makes an HTTP request to an external service.
If that service is temporarily unavailable the task should raise an ExpectedError
.
Tasks are always retried with capped exponential backoff.
UnexpectedError(String)
Should be used when a task encounters an error that is unexpected.
These errors will always be logged at the ERROR
level. The retry behavior
when this error is encountered is determined by the
TaskOptions::retry_for_unexpected
setting.
TimeoutError
Raised when a task runs over its time limit specified by the
TaskOptions::time_limit
setting.
These errors are logged at the ERROR
level but are otherwise treated like
ExpectedError
s in that they will trigger a retry when max_retries
is anything but 0.
Typically a task implementation doesn’t need to return these errors directly
because they will be raised automatically when the task runs over it’s time_limit
,
provided the task yields control at some point (like with non-blocking IO).
Retry(Option<DateTime<Utc>>)
A task can return this error variant to manually trigger a retry.
This error variant should generally not be used directly. Instead, you should
call the Task::retry_with_countdown
or Task::retry_with_eta
trait methods
to manually trigger a retry from within a task.