Skip to content

Commit

Permalink
Sync errors
Browse files Browse the repository at this point in the history
Also fixes a test broken by parser rework in nightly.
  • Loading branch information
elprans committed Jul 14, 2023
1 parent a6f78a2 commit 1604a23
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
8 changes: 8 additions & 0 deletions edgedb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
DuplicateFunctionDefinitionError,
DuplicateConstraintDefinitionError,
DuplicateCastDefinitionError,
DuplicateMigrationError,
SessionTimeoutError,
IdleSessionTimeoutError,
QueryTimeoutError,
Expand All @@ -147,6 +148,7 @@
DivisionByZeroError,
NumericOutOfRangeError,
AccessPolicyError,
QueryAssertionError,
IntegrityError,
ConstraintViolationError,
CardinalityViolationError,
Expand All @@ -155,11 +157,13 @@
TransactionConflictError,
TransactionSerializationError,
TransactionDeadlockError,
WatchError,
ConfigurationError,
AccessError,
AuthenticationError,
AvailabilityError,
BackendUnavailableError,
ServerOfflineError,
BackendError,
UnsupportedBackendFeatureError,
LogMessage,
Expand Down Expand Up @@ -234,6 +238,7 @@
"DuplicateFunctionDefinitionError",
"DuplicateConstraintDefinitionError",
"DuplicateCastDefinitionError",
"DuplicateMigrationError",
"SessionTimeoutError",
"IdleSessionTimeoutError",
"QueryTimeoutError",
Expand All @@ -244,6 +249,7 @@
"DivisionByZeroError",
"NumericOutOfRangeError",
"AccessPolicyError",
"QueryAssertionError",
"IntegrityError",
"ConstraintViolationError",
"CardinalityViolationError",
Expand All @@ -252,11 +258,13 @@
"TransactionConflictError",
"TransactionSerializationError",
"TransactionDeadlockError",
"WatchError",
"ConfigurationError",
"AccessError",
"AuthenticationError",
"AvailabilityError",
"BackendUnavailableError",
"ServerOfflineError",
"BackendError",
"UnsupportedBackendFeatureError",
"LogMessage",
Expand Down
6 changes: 6 additions & 0 deletions edgedb/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
'AuthenticationError',
'AvailabilityError',
'BackendUnavailableError',
'ServerOfflineError',
'BackendError',
'UnsupportedBackendFeatureError',
'LogMessage',
Expand Down Expand Up @@ -440,6 +441,11 @@ class BackendUnavailableError(AvailabilityError):
tags = frozenset({SHOULD_RETRY})


class ServerOfflineError(AvailabilityError):
_code = 0x_08_00_00_02
tags = frozenset({SHOULD_RECONNECT, SHOULD_RETRY})


class BackendError(EdgeDBError):
_code = 0x_09_00_00_00

Expand Down
12 changes: 8 additions & 4 deletions tests/test_async_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ async def test_async_parse_error_recover_01(self):
with self.assertRaises(edgedb.EdgeQLSyntaxError):
await self.client.query('select syntax error')

with self.assertRaisesRegex(edgedb.EdgeQLSyntaxError,
'Unexpected end of line'):
with self.assertRaisesRegex(
edgedb.EdgeQLSyntaxError,
r"(Unexpected end of line)|(Missing '\)')"
):
await self.client.query('select (')

with self.assertRaisesRegex(edgedb.EdgeQLSyntaxError,
'Unexpected end of line'):
with self.assertRaisesRegex(
edgedb.EdgeQLSyntaxError,
r"(Unexpected end of line)|(Missing '\)')"
):
await self.client.query_json('select (')

for _ in range(10):
Expand Down

0 comments on commit 1604a23

Please sign in to comment.