Skip to content

Commit 90cdeef

Browse files
committed
Modified logic for formatted exception message. #8165
1 parent 6d45dd4 commit 90cdeef

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

docs/en_US/release_notes_9_0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ Bug fixes
4141
| `Issue #8255 <https://github.com/pgadmin-org/pgadmin4/issues/8255>`_ - Fixed an issue where tooltip on a dropdown button is blocking access to dropdown menu.
4242
| `Issue #8256 <https://github.com/pgadmin-org/pgadmin4/issues/8256>`_ - Fix the error occurring while loading preferences on startup.
4343
| `Issue #8273 <https://github.com/pgadmin-org/pgadmin4/issues/8273>`_ - Fixed an issue where copying query tool output cell is not working if any SQL text is selected.
44+
| `Issue #8299 <https://github.com/pgadmin-org/pgadmin4/issues/8299>`_ - Ensure master password pop up is not shown on setting MASTER_PASSWORD_REQUIRED to false.

web/pgadmin/utils/driver/psycopg3/connection.py

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,26 +1675,23 @@ def _formatted_exception_msg(self, exception_obj, formatted_msg):
16751675
message
16761676
16771677
"""
1678-
if hasattr(exception_obj, 'pgerror'):
1679-
errmsg = exception_obj.pgerror
1680-
elif hasattr(exception_obj, 'diag') and \
1681-
hasattr(exception_obj.diag, 'message_detail') and\
1682-
exception_obj.diag.message_detail is not None:
1683-
errmsg = exception_obj.diag.message_detail + '\n' + \
1684-
exception_obj.diag.message_primary
1685-
else:
1686-
errmsg = str(exception_obj)
1687-
16881678
# if formatted_msg is false then return from the function
16891679
if not formatted_msg:
1680+
if hasattr(exception_obj, 'pgerror'):
1681+
errmsg = exception_obj.pgerror
1682+
elif hasattr(exception_obj, 'diag') and \
1683+
hasattr(exception_obj.diag, 'message_detail') and\
1684+
exception_obj.diag.message_detail is not None:
1685+
errmsg = (exception_obj.diag.message_primary + '\n' +
1686+
exception_obj.diag.message_detail)
1687+
else:
1688+
errmsg = str(exception_obj)
1689+
16901690
notices = self.get_notices()
1691+
errmsg = errmsg.replace('\n', '<br/>')
16911692
return errmsg if notices == '' else notices + '\n' + errmsg
16921693

1693-
# Do not append if error starts with `ERROR:` as most pg related
1694-
# error starts with `ERROR:`
1695-
if not errmsg.startswith('ERROR:'):
1696-
errmsg = gettext('ERROR: ') + errmsg + ' \n\n'
1697-
1694+
errmsg = ''
16981695
if exception_obj.diag.severity is not None \
16991696
and exception_obj.diag.message_primary is not None:
17001697
ex_diag_message = "{0}: {1}".format(
@@ -1717,29 +1714,25 @@ def _formatted_exception_msg(self, exception_obj, formatted_msg):
17171714
errmsg += gettext('SQL state: ')
17181715
errmsg += exception_obj.diag.sqlstate
17191716

1720-
if exception_obj.diag.message_detail is not None and \
1721-
'Detail:'.lower() not in errmsg.lower():
1717+
if exception_obj.diag.message_detail is not None:
17221718
if not errmsg.endswith('\n'):
17231719
errmsg += '\n'
17241720
errmsg += gettext('Detail: ')
17251721
errmsg += exception_obj.diag.message_detail
17261722

1727-
if exception_obj.diag.message_hint is not None and \
1728-
'Hint:'.lower() not in errmsg.lower():
1723+
if exception_obj.diag.message_hint is not None:
17291724
if not errmsg.endswith('\n'):
17301725
errmsg += '\n'
17311726
errmsg += gettext('Hint: ')
17321727
errmsg += exception_obj.diag.message_hint
17331728

1734-
if exception_obj.diag.statement_position is not None and \
1735-
'Character:'.lower() not in errmsg.lower():
1729+
if exception_obj.diag.statement_position is not None:
17361730
if not errmsg.endswith('\n'):
17371731
errmsg += '\n'
17381732
errmsg += gettext('Character: ')
17391733
errmsg += exception_obj.diag.statement_position
17401734

1741-
if exception_obj.diag.context is not None and \
1742-
'Context:'.lower() not in errmsg.lower():
1735+
if exception_obj.diag.context is not None:
17431736
if not errmsg.endswith('\n'):
17441737
errmsg += '\n'
17451738
errmsg += gettext('Context: ')

0 commit comments

Comments
 (0)