MCPcopy
hub / github.com/wavetermdev/waveterm / PanicHandler

Function PanicHandler

pkg/panichandler/panichandler.go:25–43  ·  view source on GitHub ↗

returns an error (wrapping the panic) if a panic occurred

(debugStr string, recoverVal any)

Source from the content-addressed store, hash-verified

23
24// returns an error (wrapping the panic) if a panic occurred
25func PanicHandler(debugStr string, recoverVal any) error {
26 if recoverVal == nil {
27 return nil
28 }
29 log.Printf("[panic] in %s: %v\n", debugStr, recoverVal)
30 debug.PrintStack()
31 if PanicTelemetryHandler != nil {
32 go func() {
33 defer func() {
34 PanicHandlerNoTelemetry("PanicTelemetryHandler", recover())
35 }()
36 PanicTelemetryHandler(debugStr)
37 }()
38 }
39 if err, ok := recoverVal.(error); ok {
40 return fmt.Errorf("panic in %s: %w", debugStr, err)
41 }
42 return fmt.Errorf("panic in %s: %v", debugStr, recoverVal)
43}

Callers 15

triggerAsyncFetchFunction · 0.92
TestCommandMethod · 0.92
TestMultiArgCommandMethod · 0.92
StreamTestCommandMethod · 0.92
runLoopMethod · 0.92
BadgeWatchPidCommandMethod · 0.92
rtnErrFunction · 0.92
SendRpcMessageMethod · 0.92

Calls 1

PanicHandlerNoTelemetryFunction · 0.85

Tested by

no test coverage detected