INNER CODE UNIT · Python

global_exception_handler

cubist38/mlx-openai-server · app/server.py:589

    async def global_exception_handler(request: Request, exc: Exception):
        """Global exception handler that logs and returns a 500 payload.

        Logs the exception (with traceback) and returns a generic JSON
        response with a 500 status code so internal errors do not leak
        implementation details to clients.
        """
        logger.error(f"Global exception handler caught: {exc!s}", exc_info=True)
        return JSONResponse(
            status_code=500,
            content={"error": {"message": "Internal server error", "type": "internal_error"}},
        )

    host = config_args.host
    port = config_args.port
    logger.info(f"Starting server on {host}:{port}")
    return uvicorn.Config(
        app=app,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…