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

Error handling: Log from the exception itself #25

Open
johannaengland opened this issue May 4, 2023 · 0 comments
Open

Error handling: Log from the exception itself #25

johannaengland opened this issue May 4, 2023 · 0 comments

Comments

@johannaengland
Copy link
Collaborator

Note: One idea I saw regarding logging of exceptions: log from the exception itself.

import logging

class MyError(Exception):
  "Helpful docs"

  def __init__(self, msg):
    logging.exception(msg)
    super().__init__(msg)

The above is as minimal as it gets, the whole thing was a bit more elaborate: Stackoverflow: comment to "Logging and raising an exception". Needs testing to see if the traceback is saved.

As later polish, this would cut down on code in plugins even further.

Originally posted by @hmpf in #24 (review)

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

1 participant