mirror of
https://github.com/kennethreitz/responder.git
synced 2026-06-05 23:00:17 +00:00
Fix broken exception handling in test_500
This commit is contained in:
@@ -13,6 +13,7 @@ import yaml
|
||||
from apispec import APISpec, yaml_utils
|
||||
from apispec.ext.marshmallow import MarshmallowPlugin
|
||||
from asgiref.wsgi import WsgiToAsgi
|
||||
from starlette.exceptions import ExceptionMiddleware
|
||||
from starlette.middleware.errors import ServerErrorMiddleware
|
||||
from starlette.lifespan import LifespanHandler
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
@@ -128,6 +129,8 @@ class API:
|
||||
|
||||
self.default_endpoint = None
|
||||
self.app = self.dispatch
|
||||
self.exception_middleware = ExceptionMiddleware(self.dispatch, debug=debug)
|
||||
self.app = self.exception_middleware
|
||||
self.add_middleware(GZipMiddleware)
|
||||
|
||||
if self.hsts_enabled:
|
||||
|
||||
@@ -478,7 +478,7 @@ def test_500(api):
|
||||
def catcher(request, exc):
|
||||
return PlainTextResponse("Suppressed error", 500)
|
||||
|
||||
api.app.add_exception_handler(ValueError, catcher)
|
||||
api.exception_middleware.add_exception_handler(ValueError, catcher)
|
||||
|
||||
@api.route("/")
|
||||
def view(req, resp):
|
||||
|
||||
Reference in New Issue
Block a user