github.com/0xPolygon/supernets2-node@v0.0.0-20230711153321-2fe574524eaa/etherman/errors.go (about) 1 package etherman 2 3 import ( 4 "errors" 5 "strings" 6 ) 7 8 var ( 9 // ErrGasRequiredExceedsAllowance gas required exceeds the allowance 10 ErrGasRequiredExceedsAllowance = errors.New("gas required exceeds allowance") 11 // ErrContentLengthTooLarge content length is too large 12 ErrContentLengthTooLarge = errors.New("content length too large") 13 //ErrTimestampMustBeInsideRange Timestamp must be inside range 14 ErrTimestampMustBeInsideRange = errors.New("timestamp must be inside range") 15 //ErrInsufficientAllowance insufficient allowance 16 ErrInsufficientAllowance = errors.New("insufficient allowance") 17 // ErrBothGasPriceAndMaxFeeGasAreSpecified both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified 18 ErrBothGasPriceAndMaxFeeGasAreSpecified = errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified") 19 // ErrMaxFeeGasAreSpecifiedButLondonNotActive maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet 20 ErrMaxFeeGasAreSpecifiedButLondonNotActive = errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet") 21 // ErrNoSigner no signer to authorize the transaction with 22 ErrNoSigner = errors.New("no signer to authorize the transaction with") 23 // ErrMissingTrieNode means that a node is missing on the trie 24 ErrMissingTrieNode = errors.New("missing trie node") 25 26 errorsCache = map[string]error{ 27 ErrGasRequiredExceedsAllowance.Error(): ErrGasRequiredExceedsAllowance, 28 ErrContentLengthTooLarge.Error(): ErrContentLengthTooLarge, 29 ErrTimestampMustBeInsideRange.Error(): ErrTimestampMustBeInsideRange, 30 ErrInsufficientAllowance.Error(): ErrInsufficientAllowance, 31 ErrBothGasPriceAndMaxFeeGasAreSpecified.Error(): ErrBothGasPriceAndMaxFeeGasAreSpecified, 32 ErrMaxFeeGasAreSpecifiedButLondonNotActive.Error(): ErrMaxFeeGasAreSpecifiedButLondonNotActive, 33 ErrNoSigner.Error(): ErrNoSigner, 34 ErrMissingTrieNode.Error(): ErrMissingTrieNode, 35 } 36 ) 37 38 func tryParseError(err error) (error, bool) { 39 parsedError, exists := errorsCache[err.Error()] 40 if !exists { 41 for errStr, actualErr := range errorsCache { 42 if strings.Contains(err.Error(), errStr) { 43 return actualErr, true 44 } 45 } 46 } 47 return parsedError, exists 48 }