Skip to content

Custom error handler not called by ServerErrorMiddleware in debug mode #1867

Answered by Kludex
alex-oleshkevich asked this question in Ideas
Discussion options

You must be logged in to vote

yes it's usable, but (don't quote me on this I may remember the stuff badly) it is not the outer layer of the middleware stack as the exception layer should be iirc, so exceptions raised after will be rendered using the starlette debugger template and not the starception one.

Can't the package recommend something like:

middleware = []
if os.getenv("DEBUG"):
    middleware.append([DebugMiddleware])

app = Starlette(middleware=middleware) # Do not use the `debug` flag!

Instead of:

middleware = [DebugMiddleware]

app = Starlette(middleware=middleware, debug=True) 

Replies: 13 comments

Comment options

You must be logged in to vote
0 replies
Comment options

Kludex
Aug 11, 2022
Maintainer Sponsor

You must be logged in to vote
0 replies
Comment options

Kludex
Aug 11, 2022
Maintainer Sponsor

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

Kludex
Sep 3, 2022
Maintainer Sponsor

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

Kludex
Sep 5, 2022
Maintainer Sponsor

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

Kludex
Sep 5, 2022
Maintainer Sponsor

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

Kludex
Sep 5, 2022
Maintainer Sponsor

You must be logged in to vote
0 replies
Answer selected by Kludex
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
feature New feature or request
4 participants
Converted from issue

This discussion was converted from issue #1802 on September 24, 2022 05:26.