1
0

panicwrap.go 971 B

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