```python from fastapi.responses import JSONResponse from posthog import Posthog posthog = Posthog('', host='') @app.exception_handler(Exception) async def http_exception_handler(request, exc): posthog.capture_exception(exc) return JSONResponse(status_code=500, content={'message': str(exc)}) ```