Skip to content

Exceptions should inherit from Exception, not BaseException #90

Closed
@soundstripe

Description

@soundstripe

It seems to me like StarletteContextError in errors.py should subclass Exception instead of BaseException.

Exceptions that inherit from BaseException are not caught by the normal try/catch idiom of:

try:
    block_of_code()
exception Exception as e:
    handle(e)

BaseException is meant for exception types that shouldn't be caught by normal handlers (SystemInterrupt, etc).

If this was an intentional decision on your part, that's fine, but I didn't see any issues or discussion about it. I'd be happy to submit a PR for this if you like.

I love this package and I use it in a few of my FastAPI projects!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions