Skip to content

Commit

Permalink
Do not check error state if null
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed Nov 21, 2024
1 parent 3ba6e2e commit f8f1da3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion awx/conf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,13 @@ def _ctit_db_wrapper(trans_safe=False):
except DatabaseError as e:
if trans_safe:
cause = e.__cause__
if cause and hasattr(cause, 'sqlstate'):
sqlstate = getattr(cause, 'sqlstate', None)

Check warning on line 100 in awx/conf/settings.py

View check run for this annotation

Codecov / codecov/patch

awx/conf/settings.py#L100

Added line #L100 was not covered by tests
if cause and sqlstate:
sqlstate = cause.sqlstate
sqlstate_str = psycopg.errors.lookup(sqlstate)
logger.error('SQL Error state: {} - {}'.format(sqlstate, sqlstate_str))
else:
logger.error(f'Error reading something related to database settings: {str(e)}.')

Check warning on line 106 in awx/conf/settings.py

View check run for this annotation

Codecov / codecov/patch

awx/conf/settings.py#L106

Added line #L106 was not covered by tests
else:
logger.exception('Error modifying something related to database settings.')
finally:
Expand Down

0 comments on commit f8f1da3

Please sign in to comment.