errors.go 771 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package vm
  2. import (
  3. "fmt"
  4. "github.com/ethereum/go-ethereum/params"
  5. )
  6. type OutOfGasError struct{}
  7. func (self OutOfGasError) Error() string {
  8. return "Out Of Gas"
  9. }
  10. func IsOOGErr(err error) bool {
  11. _, ok := err.(OutOfGasError)
  12. return ok
  13. }
  14. type StackError struct {
  15. req, has int
  16. }
  17. func StackErr(req, has int) StackError {
  18. return StackError{req, has}
  19. }
  20. func (self StackError) Error() string {
  21. return fmt.Sprintf("stack error! require %v, have %v", self.req, self.has)
  22. }
  23. func IsStack(err error) bool {
  24. _, ok := err.(StackError)
  25. return ok
  26. }
  27. type DepthError struct{}
  28. func (self DepthError) Error() string {
  29. return fmt.Sprintf("Max call depth exceeded (%d)", params.CallCreateDepth)
  30. }
  31. func IsDepthErr(err error) bool {
  32. _, ok := err.(DepthError)
  33. return ok
  34. }