mirror of
https://github.com/BillyOutlast/posthog.com.git
synced 2026-02-04 19:31:21 +01:00
Co-authored-by: Vincent (Wen Yu) Ge <gewenyu99@gmail.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: David Newell <david@posthog.com> Co-authored-by: edwinyjlim <edwinyjlim@gmail.com> Co-authored-by: Edwin Lim <edwin@posthog.com>
11 lines
346 B
Plaintext
11 lines
346 B
Plaintext
```python
|
|
from fastapi.responses import JSONResponse
|
|
from posthog import Posthog
|
|
|
|
posthog = Posthog('<ph_project_api_key>', host='<ph_client_api_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)})
|
|
``` |