MCPcopy
hub / github.com/fastapi/fastapi / errorhandler

Function errorhandler

tests/test_ws_router.py:242–246  ·  view source on GitHub ↗
(websocket: WebSocket, call_next)

Source from the content-addressed store, hash-verified

240
241 @websocket_middleware
242 async def errorhandler(websocket: WebSocket, call_next):
243 try:
244 return await call_next()
245 except Exception as e:
246 await websocket.close(code=status.WS_1006_ABNORMAL_CLOSURE, reason=repr(e))
247
248 myapp = make_app(middleware=[Middleware(errorhandler)])
249 client = TestClient(myapp)

Callers

nothing calls this directly

Calls 2

call_nextFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…