-
Notifications
You must be signed in to change notification settings - Fork 98
docs: added notes to ApplicationError
and FailureError
exception docstrings.
#718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
41d13a7
5672e5c
f40030b
cd244ff
98ae6f8
713f273
4378e19
df0e7f1
eedc6c3
fbfabe1
44416b0
89f9b02
ac38f6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
"""Common Temporal exceptions.""" | ||
"""Common Temporal exceptions. | ||
|
||
# Temporal Failure | ||
|
||
Most Temporal SDKs have a base class that the other Failures extend. | ||
In python, it is the ``FailureError``. | ||
|
||
# Application Failure | ||
|
||
Workflow, and Activity, and Nexus Operation code use Application Failures to | ||
communicate application-specific failures that happen. | ||
This is the only type of Temporal Failure created and thrown by user code. | ||
In the Python SDK, it is the ``ApplicationError``. | ||
|
||
# References | ||
|
||
More information can be found in the docs at | ||
https://docs.temporal.io/references/failures#workflow-execution-failures. | ||
""" | ||
|
||
import asyncio | ||
from datetime import timedelta | ||
|
@@ -23,7 +41,15 @@ def cause(self) -> Optional[BaseException]: | |
|
||
|
||
class FailureError(TemporalError): | ||
"""Base for runtime failures during workflow/activity execution.""" | ||
"""Base for runtime failures during workflow/activity execution. | ||
|
||
This is extended by ``ApplicationError``, which can be raised in a Workflow to fail the Workflow Execution. | ||
Workflow Execution Failures put the Workflow Execution into the "Failed" state and no more attempts will | ||
be made in progressing this execution. | ||
|
||
Any exception that does not extend this exception | ||
is considered a Workflow Task Failure. These types of failures will cause the Workflow Task to be retried. | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's actually more complicated than this since it is now configurable. We dedicate a section of our README to this at https://github.com/temporalio/sdk-python?tab=readme-ov-file#exceptions. Ideally we don't have to duplicate so much in here and there considering they may not say the same things, as is the case already here where it is not explained that this is customizable. |
||
|
||
GSmithApps marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def __init__( | ||
self, | ||
|
@@ -71,7 +97,26 @@ def __init__( | |
|
||
|
||
class ApplicationError(FailureError): | ||
"""Error raised during workflow/activity execution.""" | ||
"""Error raised during workflow/activity execution. | ||
|
||
Can be raised in a Workflow to fail the Workflow Execution. | ||
Workflow Execution Failures put the Workflow Execution into the "Failed" state and no more attempts will | ||
be made in progressing their execution. | ||
|
||
If you are creating custom exceptions or raising typical Python-based | ||
exceptions you would either need to extend this class or | ||
explicitly state that the exception is a Workflow Execution Failure by raising a new ``ApplicationError``. | ||
|
||
Any exception that does not extend this exception | ||
is considered a Workflow Task Failure. These types of failures will cause the Workflow Task to be retried. | ||
|
||
GSmithApps marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Example | ||
|
||
>>> from temporalio.exceptions import ApplicationError | ||
... # ... | ||
... if isDelivery and distance.get_kilometers() > 25: | ||
... raise ApplicationError("Customer lives outside the service area") | ||
""" | ||
|
||
def __init__( | ||
self, | ||
|
Uh oh!
There was an error while loading. Please reload this page.