2016-06-27 01:56:23 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
import "log"
|
|
|
|
|
2016-11-08 23:04:11 +00:00
|
|
|
// RecoverFromError doesn't really recover from anything....see comment below
|
2016-06-27 01:56:23 +00:00
|
|
|
func RecoverFromError() {
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
// This should only really happen if there is a failure de/serializing. If
|
|
|
|
// this does happen then we currently error. In the future we might be
|
|
|
|
// able to make this nicer.
|
|
|
|
log.Fatalf("Recovered from panic() - this really shouldn't happen. Reason: %v", r)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-08 23:04:11 +00:00
|
|
|
// CheckError is a helper function for panicing on errors which we need to handle
|
|
|
|
// but should be very rare e.g. failures deserializing a protobuf object that
|
|
|
|
// should only happen if there was a bug in the underlying library.
|
2016-06-27 01:56:23 +00:00
|
|
|
func CheckError(err error) {
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("%v", err))
|
|
|
|
}
|
|
|
|
}
|