2018-01-26 05:59:21 +00:00
|
|
|
package queue
|
2017-09-27 00:50:41 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/geth/common"
|
|
|
|
"github.com/status-im/status-go/geth/signal"
|
|
|
|
)
|
|
|
|
|
2017-10-20 09:06:22 +00:00
|
|
|
//ErrTxQueueRunFailure - error running transaction queue
|
2017-09-27 00:50:41 +00:00
|
|
|
var ErrTxQueueRunFailure = errors.New("error running transaction queue")
|
|
|
|
|
|
|
|
// HaltOnPanic recovers from panic, logs issue, sends upward notification, and exits
|
|
|
|
func HaltOnPanic() {
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
err := fmt.Errorf("%v: %v", ErrTxQueueRunFailure, r)
|
|
|
|
|
|
|
|
// send signal up to native app
|
|
|
|
signal.Send(signal.Envelope{
|
|
|
|
Type: signal.EventNodeCrashed,
|
|
|
|
Event: signal.NodeCrashEvent{
|
2018-02-05 10:37:59 +00:00
|
|
|
Error: err,
|
2017-09-27 00:50:41 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
common.Fatalf(err) // os.exit(1) is called internally
|
|
|
|
}
|
|
|
|
}
|