tendermint/common/errors.go

46 lines
1.3 KiB
Go
Raw Normal View History

2015-10-21 12:15:19 -07:00
package common
import (
"fmt"
)
type StackError struct {
Err interface{}
Stack []byte
}
func (se StackError) String() string {
return fmt.Sprintf("Error: %v\nStack: %s", se.Err, se.Stack)
}
func (se StackError) Error() string {
return se.String()
}
//--------------------------------------------------------------------------------------------------
// panic wrappers
// A panic resulting from a sanity check means there is a programmer error
// and some guarantee is not satisfied.
2015-10-21 12:15:19 -07:00
func PanicSanity(v interface{}) {
2016-07-13 10:50:06 -07:00
panic(Fmt("Panicked on a Sanity Check: %v", v))
2015-10-21 12:15:19 -07:00
}
// A panic here means something has gone horribly wrong, in the form of data corruption or
// failure of the operating system. In a correct/healthy system, these should never fire.
// If they do, it's indicative of a much more serious problem.
func PanicCrisis(v interface{}) {
2016-07-13 10:50:06 -07:00
panic(Fmt("Panicked on a Crisis: %v", v))
2015-10-21 12:15:19 -07:00
}
// Indicates a failure of consensus. Someone was malicious or something has
// gone horribly wrong. These should really boot us into an "emergency-recover" mode
func PanicConsensus(v interface{}) {
2016-07-13 10:50:06 -07:00
panic(Fmt("Panicked on a Consensus Failure: %v", v))
2015-10-21 12:15:19 -07:00
}
// For those times when we're not sure if we should panic
func PanicQ(v interface{}) {
2016-07-13 10:50:06 -07:00
panic(Fmt("Panicked questionably: %v", v))
2015-10-21 12:15:19 -07:00
}