app.exception_handler does not work when used in separate file #1191
-
Hi, I am using APIGatewayRestResolver and I'm having trouble working with @app.exception_handler. When I have APIGatewayRestResolver object and @app.exception_handler decorator in same file then it works but if I create a separate file for exceptions(exceptions.py) and do the import of APIGatewayRestResolver then it doesn't work.
I don't have much expertise on how decorator works so any help here would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@arunbhati in your example nothing is referencing You can verify that So maybe either reference the |
Beta Was this translation helpful? Give feedback.
@arunbhati in your example nothing is referencing
exceptions.py
so it would not call either of the@app.exception_handler
or@app.not_found
decorators.You can verify that
exceptions.py
is not being referenced by adding aprint
statement.So maybe either reference the
exceptions.py
as an import elsewhere or load it via__init__.py
, or move the logic in__init__.py__