errors.go 771 Bytes
Newer Older
1 2 3 4
package vm

import (
	"fmt"
5

6
	"github.com/ethereum/go-ethereum/params"
7 8
)

9
type OutOfGasError struct{}
10 11

func (self OutOfGasError) Error() string {
12
	return "Out Of Gas"
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
}

func IsOOGErr(err error) bool {
	_, ok := err.(OutOfGasError)
	return ok
}

type StackError struct {
	req, has int
}

func StackErr(req, has int) StackError {
	return StackError{req, has}
}

func (self StackError) Error() string {
	return fmt.Sprintf("stack error! require %v, have %v", self.req, self.has)
}

func IsStack(err error) bool {
	_, ok := err.(StackError)
	return ok
}

type DepthError struct{}

func (self DepthError) Error() string {
40
	return fmt.Sprintf("Max call depth exceeded (%d)", params.CallCreateDepth)
41 42 43 44 45 46
}

func IsDepthErr(err error) bool {
	_, ok := err.(DepthError)
	return ok
}