bottlepy / bottle

bottle.py is a fast and simple micro-framework for python web-applications.
http://bottlepy.org/
MIT License
8.37k stars 1.46k forks source link

Improve wsgi error handling 013 #1221

Closed braedon closed 3 years ago

braedon commented 4 years ago

Recommended by pep-3333 to enable middleware to provide exception handling services, e.g. custom exception logging.

See https://www.python.org/dev/peps/pep-3333/#error-handling

Note that the exc_info is temporarily stored in the environ to pass it up from _handler() to wsgi(), where start_response() is called. There may be a better way to do this, e.g. storing it in the response object.

Supersedes https://github.com/bottlepy/bottle/pull/1097, and includes the tests from @BubaVV in https://github.com/bottlepy/bottle/pull/1103

defnull commented 3 years ago

I do not fully understand if this is the best solution, but I'll trust you on this and merge. It only affects the error path, so it should not affect normal working applications. And it has tests \o/ Thanks!

braedon commented 3 years ago

Thanks @defnull, Happy New Year!