You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3 KiB

9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
8 years ago
9 years ago
  1. package common
  2. import (
  3. "fmt"
  4. )
  5. type StackError struct {
  6. Err interface{}
  7. Stack []byte
  8. }
  9. func (se StackError) String() string {
  10. return fmt.Sprintf("Error: %v\nStack: %s", se.Err, se.Stack)
  11. }
  12. func (se StackError) Error() string {
  13. return se.String()
  14. }
  15. //--------------------------------------------------------------------------------------------------
  16. // panic wrappers
  17. // A panic resulting from a sanity check means there is a programmer error
  18. // and some guarantee is not satisfied.
  19. // XXX DEPRECATED
  20. func PanicSanity(v interface{}) {
  21. panic(Fmt("Panicked on a Sanity Check: %v", v))
  22. }
  23. // A panic here means something has gone horribly wrong, in the form of data corruption or
  24. // failure of the operating system. In a correct/healthy system, these should never fire.
  25. // If they do, it's indicative of a much more serious problem.
  26. // XXX DEPRECATED
  27. func PanicCrisis(v interface{}) {
  28. panic(Fmt("Panicked on a Crisis: %v", v))
  29. }
  30. // Indicates a failure of consensus. Someone was malicious or something has
  31. // gone horribly wrong. These should really boot us into an "emergency-recover" mode
  32. // XXX DEPRECATED
  33. func PanicConsensus(v interface{}) {
  34. panic(Fmt("Panicked on a Consensus Failure: %v", v))
  35. }
  36. // For those times when we're not sure if we should panic
  37. // XXX DEPRECATED
  38. func PanicQ(v interface{}) {
  39. panic(Fmt("Panicked questionably: %v", v))
  40. }