Skip to content
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

Support Contended Transaction Errors #136

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion fauna/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import fauna
from fauna.errors import AuthenticationError, ClientError, ProtocolError, ServiceError, AuthorizationError, \
ServiceInternalError, ServiceTimeoutError, ThrottlingError, QueryTimeoutError, QueryRuntimeError, \
QueryCheckError, AbortError, InvalidRequestError
QueryCheckError, ContendedTransactionError, AbortError, InvalidRequestError
from fauna.client.headers import _DriverEnvironment, _Header, _Auth, Header
from fauna.http.http_client import HTTPClient
from fauna.query import Query, Page, fql
Expand Down Expand Up @@ -474,6 +474,18 @@ def _handle_error(self, body: Any, status_code: int):
txn_ts=txn_ts,
schema_version=schema_version,
)
elif status_code == 409:
raise ContendedTransactionError(
status_code=status_code,
code=code,
message=message,
summary=summary,
constraint_failures=constraint_failures,
query_tags=query_tags,
stats=stats,
txn_ts=txn_ts,
schema_version=schema_version,
)
elif status_code == 429:
raise ThrottlingError(
status_code=status_code,
Expand Down
2 changes: 1 addition & 1 deletion fauna/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from .errors import ClientError, FaunaError, NetworkError
from .errors import ProtocolError, ServiceError
from .errors import AuthenticationError, AuthorizationError, QueryCheckError, QueryRuntimeError, \
QueryTimeoutError, ServiceInternalError, ServiceTimeoutError, ThrottlingError, \
QueryTimeoutError, ServiceInternalError, ServiceTimeoutError, ThrottlingError, ContendedTransactionError, \
InvalidRequestError, AbortError
5 changes: 5 additions & 0 deletions fauna/errors/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ class QueryCheckError(ServiceError):
pass


class ContendedTransactionError(ServiceError):
"""Transaction is aborted due to concurrent modification."""
pass


class QueryRuntimeError(ServiceError):
"""An error response that is the result of the query failing during execution.
QueryRuntimeError's occur when a bug in your query causes an invalid execution
Expand Down