Skip to content

The option to only apply the stackprinter styles to certain exceptions (Alternatively, a whitelist/blacklist system) #67

@AbdelRahmanRahal

Description

@AbdelRahmanRahal

As the title suggests, it would be great if we were able to add the stackprinter styles to only a select exception classes.

I came across this idea while developing a module. I wanted the error messages for my module to be prettier, but I didn't want any other error messages to be affected. If I use stackprinter within my module, I essentially force the user to also have its styles for all other exceptions including the ones within their own program, or at least that's what I experienced while testing.

A way to implement this could be by specifying a list of exception classes to whitelist or blacklist (but never both):

stackprinter.set_excepthook(
    style='darkbg2',
    whitelist=[
        TypeError,
        CustomException1,
        CustomException2
    ]
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions