mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-11-14 04:05:17 +00:00
19 lines
354 B
Go
19 lines
354 B
Go
|
package catch
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"io"
|
||
|
"os"
|
||
|
"runtime/debug"
|
||
|
)
|
||
|
|
||
|
var panicWriter io.Writer = os.Stderr
|
||
|
|
||
|
// HandlePanic handles and logs panics.
|
||
|
func HandlePanic(rerr interface{}, err *error, where string) {
|
||
|
if rerr != nil {
|
||
|
fmt.Fprintf(panicWriter, "caught panic: %s\n%s\n", rerr, debug.Stack())
|
||
|
*err = fmt.Errorf("panic in %s: %s", where, rerr)
|
||
|
}
|
||
|
}
|