MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / exception_handler

Function exception_handler

methods/cognee/api/client.py:89–104  ·  view source on GitHub ↗
(_: Request, exc: CogneeApiError)

Source from the content-addressed store, hash-verified

87
88@app.exception_handler(CogneeApiError)
89async def exception_handler(_: Request, exc: CogneeApiError) -> JSONResponse:
90 detail = {}
91
92 if exc.name and exc.message and exc.status_code:
93 status_code = exc.status_code
94 detail["message"] = f"{exc.message} [{exc.name}]"
95 else:
96 # Log an error indicating the exception is improperly defined
97 logger.error("Improperly defined exception: %s", exc)
98 # Provide a default error response
99 detail["message"] = "An unexpected error occurred."
100 status_code = status.HTTP_418_IM_A_TEAPOT
101
102 # log the stack trace for easier serverside debugging
103 logger.error(format_exc())
104 return JSONResponse(status_code=status_code, content={"detail": detail["message"]})
105
106
107app.include_router(get_auth_router(), prefix="/api/v1/auth", tags=["auth"])

Callers

nothing calls this directly

Calls 1

errorMethod · 0.65

Tested by

no test coverage detected