Capture panics

This commit is contained in:
Kegan Dougal 2021-03-23 18:37:44 +00:00
parent a850a2dd15
commit 79db90f3fb

View file

@ -67,6 +67,15 @@ func MakeAuthAPI(
hub.Scope().SetTag("user_id", device.UserID)
hub.Scope().SetTag("device_id", device.ID)
}
defer func() {
if r := recover(); r != nil {
if hub != nil {
hub.CaptureException(fmt.Errorf("%s panicked", req.URL.Path))
}
// re-panic to return the 500
panic(r)
}
}()
jsonRes := f(req, device)
// do not log 4xx as errors as they are client fails, not server fails