Fix broken exception handling in test_500

This commit is contained in:
Andrew Stiles
2018-11-21 11:30:31 -06:00
parent 4001a60f6c
commit b8fa923ec9
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -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:
+1 -1
View File
@@ -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):