MCPcopy Create free account
hub / github.com/pace/bricks / HandleWithCtx

Function HandleWithCtx

maintenance/errors/error.go:210–217  ·  view source on GitHub ↗

HandleWithCtx should be called with defer to recover panics in goroutines

(ctx context.Context, handlerName string)

Source from the content-addressed store, hash-verified

208
209// HandleWithCtx should be called with defer to recover panics in goroutines
210func HandleWithCtx(ctx context.Context, handlerName string) {
211 if r := recover(); r != nil {
212 log.Ctx(ctx).Error().Str("handler", handlerName).Msgf("Panic: %v", r)
213 log.Stack(ctx)
214
215 sentry.CaptureEvent(getEvent(ctx, nil, NewPanic(r), 2, handlerName))
216 }
217}
218
219func HandleErrorNoStack(ctx context.Context, err error) {
220 log.Ctx(ctx).Info().Msgf("Received error, will not handle further: %v", err)

Callers 8

mainFunction · 0.92
RunMethod · 0.92
registerHealthCheckFunction · 0.92
ServerFunction · 0.92
HealthCheckMethod · 0.92
RunFunction · 0.92
singleRunMethod · 0.92
TestHandleWithCtxFunction · 0.85

Calls 5

CtxFunction · 0.92
StackFunction · 0.92
getEventFunction · 0.85
NewPanicFunction · 0.85
ErrorMethod · 0.45

Tested by 1

TestHandleWithCtxFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…