github.com/iotexproject/iotex-core@v1.14.1-rc1/action/const.go (about)

     1  // Copyright (c) 2019 IoTeX Foundation
     2  // This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability
     3  // or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed.
     4  // This source code is governed by Apache License 2.0 that can be found in the LICENSE file.
     5  
     6  package action
     7  
     8  import "github.com/pkg/errors"
     9  
    10  // vars
    11  var (
    12  	ErrAddress            = errors.New("invalid address")
    13  	ErrVotee              = errors.New("votee is not a candidate")
    14  	ErrNotFound           = errors.New("action not found")
    15  	ErrChainID            = errors.New("invalid chainID")
    16  	ErrExistedInPool      = errors.New("known transaction")
    17  	ErrReplaceUnderpriced = errors.New("replacement transaction underpriced")
    18  	ErrSystemActionNonce  = errors.New("invalid system action nonce")
    19  	ErrNonceTooLow        = errors.New("nonce too low")
    20  	ErrUnderpriced        = errors.New("transaction underpriced")
    21  	ErrNegativeValue      = errors.New("negative value")
    22  	ErrIntrinsicGas       = errors.New("intrinsic gas too low")
    23  	ErrInsufficientFunds  = errors.New("insufficient funds for gas * price + value")
    24  	ErrNonceTooHigh       = errors.New("nonce too high")
    25  	ErrInvalidSender      = errors.New("invalid sender")
    26  	ErrTxPoolOverflow     = errors.New("txpool is full")
    27  	ErrGasLimit           = errors.New("exceeds block gas limit")
    28  	ErrOversizedData      = errors.New("oversized data")
    29  	ErrNilProto           = errors.New("empty action proto to load")
    30  	ErrNilAction          = errors.New("nil action to load proto")
    31  	ErrInvalidAct         = errors.New("invalid action type")
    32  	ErrInvalidABI         = errors.New("invalid abi binary data")
    33  )
    34  
    35  // LoadErrorDescription loads corresponding description related to the error
    36  func LoadErrorDescription(err error) string {
    37  	switch errors.Cause(err) {
    38  	case ErrOversizedData, ErrTxPoolOverflow, ErrInvalidSender, ErrNonceTooHigh, ErrInsufficientFunds, ErrIntrinsicGas, ErrChainID, ErrNotFound, ErrVotee, ErrAddress, ErrExistedInPool, ErrReplaceUnderpriced, ErrNonceTooLow, ErrUnderpriced, ErrNegativeValue:
    39  		return err.Error()
    40  	default:
    41  		return "Unknown"
    42  	}
    43  }