Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control exceptions silencing in DEBUG with a new setting #247

Open
dferens opened this issue Mar 9, 2023 · 2 comments
Open

Control exceptions silencing in DEBUG with a new setting #247

dferens opened this issue Mar 9, 2023 · 2 comments

Comments

@dferens
Copy link
Contributor

dferens commented Mar 9, 2023

Hi,

Before making a PR, I'd like to know if you will support this idea or no.

Behavior of easyaudit is to silence any exception in signal handlers, which is what you need on prod:

except Exception:
pass
except Exception:
logger.exception('easy audit had a pre-save exception.')

But during development it's better to know that something isn't working in your signal handlers.

I propose to add a setting which will enable raising exceptions if DEBUG is True:

DJANGO_EASY_AUDIT_DEBUG_EXCEPTIONS=True  # False by default for backwards compat.
try:
    ...
except Exception:
    if settings.DEBUG and easyaudit.settings.DEBUG_EXCEPTIONS:
        raise
    else:
        pass

Let me know what you think.

Thanks!

@jheld
Copy link
Collaborator

jheld commented Mar 13, 2023

Definitely, good idea

@Alex-Sichkar
Copy link

I've noticed that the pull request has already been merged. Are you certain that this will work as expected within transactions? The code re-raises exceptions from the crud_flow() callback, which is itself a transaction.on_commit() callback. In my case, it does not work as expected, exceptions are always thrown and cannot be silenced.

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

No branches or pull requests

3 participants