INNER CODE UNIT · Python

global_exception_handler

mfmezger/conversational-agent-langchain · src/agent/api.py:123

async def global_exception_handler(request: Request, exc: Exception) -> JSONResponse:
    """Global exception handler."""
    logger.error(f"Global error: {exc}")
    if _is_openai_path(request.url.path):
        return _openai_error_response(
            status_code=500,
            message="Internal server error.",
            error_type="server_error",
            param=None,
            code="internal_error",
        )
    return JSONResponse(
        status_code=500,
        content={"error": "Internal Server Error", "details": str(exc)},
    )


logger.info("Loading REST API Finished.")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…