| 43 | } |
| 44 | |
| 45 | func (r *reporter) Report(err errctx.Error, req *http.Request, meta map[string]any) { |
| 46 | hub := r.hub.Clone() |
| 47 | hub.Scope().SetRequest(req) |
| 48 | hub.Scope().SetLevel(sentry.LevelError) |
| 49 | |
| 50 | if meta != nil { |
| 51 | hub.Scope().SetContext("Processing context", meta) |
| 52 | } |
| 53 | |
| 54 | // imgproxy may wrap errors using errctx.WrappedError to add context, so Sentry |
| 55 | // would report the error type as *errctx.WrappedError. |
| 56 | // |
| 57 | // To avoid this, we create the event manually from the original error |
| 58 | // and set the correct error type. |
| 59 | if event := hub.Client().EventFromException(err, sentry.LevelError); event != nil { |
| 60 | // Sentry reports errors in the reverse order: the last one is the outermost error. |
| 61 | // So we need to set the type on the last exception. |
| 62 | event.Exception[len(event.Exception)-1].Type = errctx.ErrorType(err) |
| 63 | hub.CaptureEvent(event) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | func (r *reporter) Close() { |
| 68 | r.hub.Flush(flushTimeout) |