forked from bugsnag/bugsnag-go
/
panicwrap.go
31 lines (25 loc) · 871 Bytes
/
panicwrap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// +build !appengine
package bugsnag
import (
"github.com/bugsnag/bugsnag-go/errors"
"github.com/bugsnag/panicwrap"
)
// Forks and re-runs your program to add panic monitoring. This function does
// not return on one process, instead listening on stderr of the other process,
// which returns nil.
//
// Related: https://godoc.org/github.com/bugsnag/panicwrap#BasicMonitor
func defaultPanicHandler() {
defer defaultNotifier.dontPanic()
err := panicwrap.BasicMonitor(func(output string) {
toNotify, err := errors.ParsePanic(output)
if err != nil {
defaultNotifier.Config.logf("bugsnag.handleUncaughtPanic: %v", err)
}
state := HandledState{SeverityReasonUnhandledPanic, SeverityError, true, ""}
Notify(toNotify, state, Configuration{Synchronous: true})
})
if err != nil {
defaultNotifier.Config.logf("bugsnag.handleUncaughtPanic: %v", err)
}
}