INNER CODE UNIT · Python

register_exception_handlers

mostly-ai/mostlyai · mostlyai/sdk/_local/server.py:121

    def register_exception_handlers(self):
        @self._app.exception_handler(Exception)
        async def global_exception_handler(request, exc):
            if isinstance(exc, ValidationError):
                return JSONResponse(status_code=422, content={"detail": str(exc)})
            # for fastapi.HTTPException: it will be raised as is
            # for other unhandled exceptions: client will receive a 500 Internal Server Error
            raise exc

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…