Skip to content

Commit

Permalink
Merge branch 'main' into skip_implicit_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
cofin committed Aug 21, 2023
2 parents 13427d5 + 0ae74de commit 3ad15b7
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions litestar/_asgi/routing_trie/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def build_route_middleware_stack(

# we wrap the route.handle method in the ExceptionHandlerMiddleware
asgi_handler = wrap_in_exception_handler(
debug=app.debug, app=route.handle, exception_handlers=route_handler.resolve_exception_handlers() # type: ignore[arg-type]
app=route.handle, exception_handlers=route_handler.resolve_exception_handlers() # type: ignore[arg-type]
)

if app.csrf_config:
Expand All @@ -209,7 +209,6 @@ def build_route_middleware_stack(

# we wrap the entire stack again in ExceptionHandlerMiddleware
return wrap_in_exception_handler(
debug=app.debug,
app=cast("ASGIApp", asgi_handler),
exception_handlers=route_handler.resolve_exception_handlers(),
) # pyright: ignore
5 changes: 2 additions & 3 deletions litestar/_asgi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
from litestar.types import ASGIApp, ExceptionHandlersMap, RouteHandlerType


def wrap_in_exception_handler(debug: bool, app: ASGIApp, exception_handlers: ExceptionHandlersMap) -> ASGIApp:
def wrap_in_exception_handler(app: ASGIApp, exception_handlers: ExceptionHandlersMap) -> ASGIApp:
"""Wrap the given ASGIApp in an instance of ExceptionHandlerMiddleware.
Args:
debug: Dictates whether exceptions are raised in debug mode.
app: The ASGI app that is being wrapped.
exception_handlers: A mapping of exceptions to handler functions.
Expand All @@ -24,7 +23,7 @@ def wrap_in_exception_handler(debug: bool, app: ASGIApp, exception_handlers: Exc
"""
from litestar.middleware.exceptions import ExceptionHandlerMiddleware

return ExceptionHandlerMiddleware(app=app, exception_handlers=exception_handlers, debug=debug)
return ExceptionHandlerMiddleware(app=app, exception_handlers=exception_handlers, debug=None)


def get_route_handlers(route: BaseRoute) -> list[RouteHandlerType]:
Expand Down
2 changes: 1 addition & 1 deletion litestar/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ def _create_asgi_handler(self) -> ASGIApp:
asgi_handler = CORSMiddleware(app=asgi_handler, config=self.cors_config)

return wrap_in_exception_handler(
debug=self.debug, app=asgi_handler, exception_handlers=self.exception_handlers or {} # pyright: ignore
app=asgi_handler, exception_handlers=self.exception_handlers or {} # pyright: ignore
)

def _wrap_send(self, send: Send, scope: Scope) -> Send:
Expand Down
2 changes: 1 addition & 1 deletion litestar/security/session_auth/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
exception_middleware = ExceptionHandlerMiddleware(
app=auth_middleware,
exception_handlers=litestar_app.exception_handlers or {}, # pyright: ignore
debug=litestar_app.debug,
debug=None,
)
self.app = SessionMiddleware(
app=exception_middleware,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def app() -> Litestar:

@pytest.fixture()
def middleware() -> ExceptionHandlerMiddleware:
return ExceptionHandlerMiddleware(dummy_app, False, {})
return ExceptionHandlerMiddleware(dummy_app, None, {})


@pytest.fixture()
Expand Down

0 comments on commit 3ad15b7

Please sign in to comment.