github.com/ontio/ontology@v1.14.4/vm/evm/errors.go (about)

     1  // Copyright (C) 2021 The Ontology Authors
     2  // Copyright 2014 The go-ethereum Authors
     3  // This file is part of the go-ethereum library.
     4  //
     5  // The go-ethereum library is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU Lesser General Public License as published by
     7  // the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  //
    10  // The go-ethereum library is distributed in the hope that it will be useful,
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  // GNU Lesser General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU Lesser General Public License
    16  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    17  
    18  package evm
    19  
    20  import (
    21  	"fmt"
    22  )
    23  
    24  // ErrStackUnderflow wraps an evm error when the items on the stack less
    25  // than the minimal requirement.
    26  type ErrStackUnderflow struct {
    27  	stackLen int
    28  	required int
    29  }
    30  
    31  func (e *ErrStackUnderflow) Error() string {
    32  	return fmt.Sprintf("stack underflow (%d <=> %d)", e.stackLen, e.required)
    33  }
    34  
    35  // ErrStackOverflow wraps an evm error when the items on the stack exceeds
    36  // the maximum allowance.
    37  type ErrStackOverflow struct {
    38  	stackLen int
    39  	limit    int
    40  }
    41  
    42  func (e *ErrStackOverflow) Error() string {
    43  	return fmt.Sprintf("stack limit reached %d (%d)", e.stackLen, e.limit)
    44  }
    45  
    46  // ErrInvalidOpCode wraps an evm error when an invalid opcode is encountered.
    47  type ErrInvalidOpCode struct {
    48  	opcode OpCode
    49  }
    50  
    51  func (e *ErrInvalidOpCode) Error() string { return fmt.Sprintf("invalid opcode: %s", e.opcode) }