Skip to content

Error handling: Log from the exception itself #25

@johannaengland

Description

@johannaengland

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions