diff options
author | obscuren <geffobscura@gmail.com> | 2014-10-23 20:04:00 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-10-23 20:04:00 +0800 |
commit | feef194829b07570e91873ed5d1e8cc51e8fa430 (patch) | |
tree | 7ccb57a57bc538c8ae242fcad95f96218b21862e /vm/errors.go | |
parent | 91c876831a3b616beb759c30d705407845ffc3ee (diff) | |
download | go-tangerine-feef194829b07570e91873ed5d1e8cc51e8fa430.tar.gz go-tangerine-feef194829b07570e91873ed5d1e8cc51e8fa430.tar.zst go-tangerine-feef194829b07570e91873ed5d1e8cc51e8fa430.zip |
Chnged to use GetOp instead & added error + checking
Diffstat (limited to 'vm/errors.go')
-rw-r--r-- | vm/errors.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/vm/errors.go b/vm/errors.go new file mode 100644 index 000000000..ab011bd62 --- /dev/null +++ b/vm/errors.go @@ -0,0 +1,51 @@ +package vm + +import ( + "fmt" + "math/big" +) + +type OutOfGasError struct { + req, has *big.Int +} + +func OOG(req, has *big.Int) OutOfGasError { + return OutOfGasError{req, has} +} + +func (self OutOfGasError) Error() string { + return fmt.Sprintf("out of gas! require %v, have %v", self.req, self.has) +} + +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 { + return fmt.Sprintf("Max call depth exceeded (%d)", MaxCallDepth) +} + +func IsDepthErr(err error) bool { + _, ok := err.(DepthError) + return ok +} |