github.com/karalabe/go-ethereum@v0.8.5/vm/errors.go (about)

     1  package vm
     2  
     3  import (
     4  	"fmt"
     5  	"math/big"
     6  )
     7  
     8  type OutOfGasError struct {
     9  	req, has *big.Int
    10  }
    11  
    12  func OOG(req, has *big.Int) OutOfGasError {
    13  	return OutOfGasError{req, has}
    14  }
    15  
    16  func (self OutOfGasError) Error() string {
    17  	return fmt.Sprintf("out of gas! require %v, have %v", self.req, self.has)
    18  }
    19  
    20  func IsOOGErr(err error) bool {
    21  	_, ok := err.(OutOfGasError)
    22  	return ok
    23  }
    24  
    25  type StackError struct {
    26  	req, has int
    27  }
    28  
    29  func StackErr(req, has int) StackError {
    30  	return StackError{req, has}
    31  }
    32  
    33  func (self StackError) Error() string {
    34  	return fmt.Sprintf("stack error! require %v, have %v", self.req, self.has)
    35  }
    36  
    37  func IsStack(err error) bool {
    38  	_, ok := err.(StackError)
    39  	return ok
    40  }
    41  
    42  type DepthError struct{}
    43  
    44  func (self DepthError) Error() string {
    45  	return fmt.Sprintf("Max call depth exceeded (%d)", MaxCallDepth)
    46  }
    47  
    48  func IsDepthErr(err error) bool {
    49  	_, ok := err.(DepthError)
    50  	return ok
    51  }