panicwrap.go 863 B

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