Skip to content

Commit

Permalink
Sync errors (#449)
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 authored and msullivan committed Aug 9, 2023
1 parent 47eec19 commit 3bfb574
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 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 @@ -61,12 +61,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
12 changes: 8 additions & 4 deletions tests/test_sync_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ def test_sync_parse_error_recover_01(self):
with self.assertRaises(edgedb.EdgeQLSyntaxError):
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 '\)')"
):
self.client.query('select (')

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

for _ in range(10):
Expand Down

0 comments on commit 3bfb574

Please sign in to comment.