From: Karl O. Pinc Date: Sat, 22 Jun 2024 04:21:32 +0000 (-0500) Subject: Avoid crash when a psycopg DatabaseError has no info from the db X-Git-Url: https://papio.biology.duke.edu/gitweb/?a=commitdiff_plain;h=5e3334e93e3a893c5ebfc8dc5f75b046d34d16d9;p=pgwui_core Avoid crash when a psycopg DatabaseError has no info from the db --- diff --git a/src/pgwui_core/exceptions.py b/src/pgwui_core/exceptions.py index 0fd7b1f..e9be180 100644 --- a/src/pgwui_core/exceptions.py +++ b/src/pgwui_core/exceptions.py @@ -204,7 +204,12 @@ class DBError(SetupError): Produce an html formatted message from a psycopg3 DatabaseError exception. ''' - primary = html_escape(ex.diag.message_primary) + if ex.diag.message_primary is None: + # Produce _something_ in those cases where the message is from + # psycopg and not the db. + primary = str(ex) + else: + primary = html_escape(ex.diag.message_primary) if ex.diag.message_detail is None: detail = ''