Skip to content

Commit b51b50d

Browse files
committed
Fix error-wrapping for callback in RecoverWithHandler
This earlier typo masked a type mismatch that had to be handled too. The result of recover() is any, but mostly errors and sometimes strings.
1 parent 0ebf8ca commit b51b50d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/common/recover.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ func RecoverWithHandler(ctx context.Context, callback func(error)) {
4040
ctx.Logger().Error(fmt.Errorf("panic"), panicStack,
4141
"recover", err,
4242
)
43-
callback(fmt.Errorf("panic: %e", err))
43+
44+
switch v := err.(type) {
45+
case error:
46+
callback(fmt.Errorf("panic: %w", v))
47+
default:
48+
callback(fmt.Errorf("panic: %v", v))
49+
}
4450
}
4551
}
4652

0 commit comments

Comments
 (0)