Skip to content

Fix exception logging#161

Merged
apriltuesday merged 1 commit into
EBIvariation:mainfrom
apriltuesday:fix-exception-logging
May 7, 2026
Merged

Fix exception logging#161
apriltuesday merged 1 commit into
EBIvariation:mainfrom
apriltuesday:fix-exception-logging

Conversation

@apriltuesday
Copy link
Copy Markdown
Contributor

@apriltuesday apriltuesday commented May 5, 2026

The current logging results in cryptic NoneType: None error messages, due to the fact that logger.exception does not work outside a handler / except clause (see here).

>>> def f():
...     raise ValueError('bad thing')
>>> try:
...     f()
... except Exception as e:
...     caught = e
>>> logger.exception(caught)

bad thing
NoneType: None

>>> try:
...    f()
... except Exception as e:
...     logger.exception(e)
    
bad thing
Traceback (most recent call last):
  File "<input>", line 2, in <module>
  File "<input>", line 2, in f
ValueError: bad thing

I don't think we need both the print and the logger.exception, but we can change it if desired.

@apriltuesday apriltuesday self-assigned this May 5, 2026
@apriltuesday apriltuesday requested review from nitin-ebi and tcezard May 5, 2026 14:43
Copy link
Copy Markdown
Member

@tcezard tcezard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Alternatively we could format and write the stack trace ourselves if we didn't want to repeat the logger.exception statement too many times:

import traceback
traceback.format_exc(caught_exception)

@apriltuesday apriltuesday marked this pull request as ready for review May 7, 2026 09:26
@apriltuesday apriltuesday merged commit 9d464e1 into EBIvariation:main May 7, 2026
4 checks passed
@apriltuesday apriltuesday deleted the fix-exception-logging branch May 7, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants