Skip to content

Commit

Permalink
[FIX] fastapi: Handle error occurring outside the fastapi processing
Browse files Browse the repository at this point in the history
To ensure that exception orrurring outside of the fastapi processing stack are properly handled, implement the 'handle_error' method into the FastApiDispatcher class
  • Loading branch information
lmignon committed Oct 1, 2024
1 parent 448ac10 commit 84e07e8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fastapi/fastapi_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from contextlib import contextmanager
from io import BytesIO

from werkzeug.exceptions import InternalServerError

from odoo.http import Dispatcher, request

from .context import odoo_env_ctx
Expand Down Expand Up @@ -35,7 +37,10 @@ def dispatch(self, endpoint, args):
)

def handle_error(self, exc):
pass
# At this stage all the normal exceptions are handled by FastAPI
# and we should only have InternalServerError occurring after the
# FastAPI app has been called.
return InternalServerError() # pragma: no cover

def _make_response(self, status_mapping, headers_tuple, content):
self.status = status_mapping[:3]
Expand Down

0 comments on commit 84e07e8

Please sign in to comment.