-
-
Notifications
You must be signed in to change notification settings - Fork 44
Description
I noticed that the following response from Aurora Postgresql Serverless V2 was not being captured as a specific PostgreSQL error, but instead reported as a generic DatabaseError:
An error occurred (DatabaseErrorException) when calling the ExecuteStatement operation: ERROR: update or delete on table "song_sheets" violates foreign key constraint "setlist_sheets_song_sheet_id_fkey" on table "setlist_sheets"; SQLState: 23503
This is because the regex that looks for the SQLState code in the error message is a little more specific than it needs to be:
aurora-data-api/aurora_data_api/base.py
Line 196 in 6f81da3
| res = re.search(r"ERROR: .*(?:\n |;) Position: (\d+); SQLState: (\w+)$", error_msg) |
The Position: field is required to match, but it isn't passed along to the PostgreSQLError, so it seems superfluous. I'm not sure, but removing the Position: match would probably help with more than just the above error (ER_FOREIGN_KEY_VIOLATION).
Thanks for this package, it's very useful!