-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new base class for exceptions, added templates (#393)
* Added new base class for exceptions, added templates Signed-off-by: chandr-andr (Kiselev Aleksandr) <chandr@chandr.net>
- Loading branch information
1 parent
40f5579
commit 8e14595
Showing
9 changed files
with
86 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,103 @@ | ||
class TaskiqError(Exception): | ||
from typing import Optional | ||
|
||
from izulu import root | ||
|
||
|
||
class TaskiqError(root.Error): | ||
"""Base exception for all errors.""" | ||
|
||
__template__ = "Exception occurred" | ||
|
||
|
||
class TaskiqResultTimeoutError(TaskiqError): | ||
"""Waiting for task results has timed out.""" | ||
|
||
__template__ = "Waiting for task results has timed out, timeout={timeout}" | ||
timeout: Optional[float] = None | ||
|
||
|
||
class BrokerError(TaskiqError): | ||
"""Base class for all broker errors.""" | ||
|
||
__template__ = "Base exception for all broker errors" | ||
|
||
|
||
class ListenError(TaskiqError): | ||
"""Error if the broker is unable to listen to the queue.""" | ||
|
||
|
||
class SharedBrokerListenError(ListenError): | ||
"""Error when someone tries to listen to the queue with shared broker.""" | ||
|
||
__template__ = "Shared broker cannot listen" | ||
|
||
|
||
class SendTaskError(BrokerError): | ||
"""Error if the broker was unable to send the task to the queue.""" | ||
|
||
__template__ = "Cannot send task to the queue" | ||
|
||
|
||
class SharedBrokerSendTaskError(SendTaskError): | ||
"""Error when someone tries to send task with shared broker.""" | ||
|
||
__template__ = ( | ||
"You cannot use kiq directly on shared task " | ||
"without setting the default_broker." | ||
) | ||
|
||
|
||
class UnknownTaskError(SendTaskError): | ||
"""Error if task is unknown.""" | ||
|
||
__template__ = "Cannot send unknown task to the queue, task name - {task_name}" | ||
task_name: str | ||
|
||
|
||
class ResultBackendError(TaskiqError): | ||
"""Base class for all ResultBackend errors.""" | ||
|
||
__template__ = "Base exception for all result backend errors" | ||
|
||
|
||
class ResultGetError(ResultBackendError): | ||
"""Error if ResultBackend was unable to get result.""" | ||
|
||
__template__ = "Cannot get result for the task" | ||
|
||
|
||
class ResultSetError(ResultBackendError): | ||
"""Error if ResultBackend was unable to set result.""" | ||
|
||
__template__ = "Cannot set result for the task" | ||
|
||
|
||
class ResultIsReadyError(ResultBackendError): | ||
"""Error if ResultBackend was unable to find out if the task is ready.""" | ||
|
||
__template__ = "Cannot find out if the task is ready" | ||
|
||
|
||
class SecurityError(TaskiqError): | ||
"""Security related exception.""" | ||
|
||
__template__ = "Security exception occurred: {description}" | ||
description: str | ||
|
||
|
||
class NoResultError(TaskiqError): | ||
"""Error if user does not want to set result.""" | ||
|
||
__template__ = "User doesn't want to set result" | ||
|
||
|
||
class TaskRejectedError(TaskiqError): | ||
"""Task was rejected.""" | ||
|
||
__template__ = "Task was rejected" | ||
|
||
|
||
class ScheduledTaskCancelledError(TaskiqError): | ||
"""Scheduled task was cancelled and not sent to the queue.""" | ||
|
||
__template__ = "Cannot send scheduled task to the queue." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters