Skip to content

Commit

Permalink
Fixed handling of DuplicateKeyException errors after crate-python 0.34
Browse files Browse the repository at this point in the history
After an improvement in crate-python 0.34, this error case is conveyed
through `IntegrityError`. Beforehand, a more generic `ProgrammingError`
was used.

Without the update, a duplicate key exception causes crash to exit
prematurely and unexpectedly, when using more recent versions of
crate-python.

Now, both exception types will be handled in the same way.
  • Loading branch information
amotl committed Apr 24, 2024
1 parent 130f781 commit 905e8dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Changes for crash
Unreleased
==========

- Fixed handling of ``DuplicateKeyException`` errors. After an improvement in
crate-python 0.34, this error case is conveyed through ``IntegrityError``.
Beforehand, a more generic ``ProgrammingError`` was used. Thanks, @romseygeek
and @proddata.

2024/03/19 0.31.4
=================

Expand Down
4 changes: 2 additions & 2 deletions crate/crash/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from verlib2 import Version

from crate.client import connect
from crate.client.exceptions import ConnectionError, ProgrammingError
from crate.client.exceptions import ConnectionError, IntegrityError, ProgrammingError

from ..crash import __version__ as crash_version
from .commands import Command, built_in_commands
Expand Down Expand Up @@ -452,7 +452,7 @@ def _exec(self, statement: str) -> bool:
self.logger.warn(str(e))
self.logger.warn(
'Use \\connect <server> to connect to one or more servers first.')
except ProgrammingError as e:
except (ProgrammingError, IntegrityError) as e:
self.logger.critical(e.message)
if self.error_trace and e.error_trace:
self.logger.critical('\n' + e.error_trace)
Expand Down

0 comments on commit 905e8dc

Please sign in to comment.