Documentation ¶
Index ¶
- func As(err error, target interface{}) bool
- func HandleRuntimeError(err error) error
- func HasErrorCode(err error, code ErrorCode) bool
- func Is(err error, target error) bool
- func IsALedgerFailure(err error) bool
- func IsAccountAccountPublicKeyNotFoundError(err error) bool
- func IsAccountNotFoundError(err error) bool
- func IsCadenceRuntimeError(err error) bool
- func IsComputationLimitExceededError(err error) bool
- func IsFailure(err error) bool
- func IsInvalidEnvelopeSignatureError(err error) bool
- func IsInvalidPayloadSignatureError(err error) bool
- func IsLedgerInteractionLimitExceededError(err error) bool
- func IsMemoryLimitExceededError(err error) bool
- func IsOperationNotSupportedError(err error) bool
- func IsStorageCapacityExceededError(err error) bool
- func IsValueError(err error) bool
- func NewCodedError(code ErrorCode, format string, formatArguments ...interface{}) codedError
- func SplitErrorTypes(inp error) (err CodedError, failure CodedError)
- func WrapCodedError(code ErrorCode, err error, prefixMsgFormat string, ...) codedError
- type CodedError
- func Find(err error, code ErrorCode) CodedError
- func NewAccountAlreadyExistsError(address flow.Address) CodedError
- func NewAccountAuthorizationErrorf(address flow.Address, msg string, args ...interface{}) CodedError
- func NewAccountNotFoundError(address flow.Address) CodedError
- func NewAccountPublicKeyLimitError(address flow.Address, counts uint64, limit uint64) CodedError
- func NewAccountPublicKeyNotFoundError(address flow.Address, keyIndex uint64) CodedError
- func NewBlockFinderFailure(err error) CodedError
- func NewCadenceRuntimeError(err runtime.Error) CodedError
- func NewComputationLimitExceededError(limit uint64) CodedError
- func NewContractNotFoundError(address flow.Address, contract string) CodedError
- func NewCouldNotGetExecutionParameterFromStateError(address string, path string) CodedError
- func NewEncodingFailuref(err error, msg string, args ...interface{}) CodedError
- func NewEventLimitExceededError(totalByteSize uint64, limit uint64) CodedError
- func NewFrozenAccountError(address flow.Address) CodedError
- func NewInvalidAddressErrorf(address flow.Address, msg string, args ...interface{}) CodedError
- func NewInvalidArgumentErrorf(msg string, args ...interface{}) CodedError
- func NewInvalidEnvelopeSignatureError(txnSig flow.TransactionSignature, err error) CodedError
- func NewInvalidLocationErrorf(location runtime.Location, msg string, args ...interface{}) CodedError
- func NewInvalidPayloadSignatureError(txnSig flow.TransactionSignature, err error) CodedError
- func NewInvalidProposalSeqNumberError(proposal flow.ProposalKey, currentSeqNumber uint64) CodedError
- func NewInvalidProposalSignatureError(proposal flow.ProposalKey, err error) CodedError
- func NewLedgerFailure(err error) CodedError
- func NewLedgerInteractionLimitExceededError(used uint64, limit uint64) CodedError
- func NewMemoryLimitExceededError(limit uint64) CodedError
- func NewOperationAuthorizationErrorf(operation string, msg string, args ...interface{}) CodedError
- func NewOperationNotSupportedError(operation string) CodedError
- func NewParseRestrictedModeInvalidAccessFailure(op string) CodedError
- func NewScriptExecutionCancelledError(err error) CodedError
- func NewScriptExecutionTimedOutError() CodedError
- func NewStateKeySizeLimitError(owner string, key string, size uint64, limit uint64) CodedError
- func NewStateMergeFailure(err error) CodedError
- func NewStateValueSizeLimitError(value flow.RegisterValue, size uint64, limit uint64) CodedError
- func NewStorageCapacityExceededError(address flow.Address, storageUsed uint64, storageCapacity uint64) CodedError
- func NewTransactionFeeDeductionFailedError(payer flow.Address, txFees uint64, err error) CodedError
- func NewUnknownFailure(err error) CodedError
- func NewValueErrorf(valueStr string, msg string, args ...interface{}) CodedError
- type ErrorCode
- type FrozenAccountError
- type InvalidProposalSeqNumberError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As ¶
As is a utility function to call std error lib `As` function. As finds the first error in err's chain that matches target, and if so, sets target to that error value and returns true. Otherwise, it returns false. The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling Unwrap.
func HandleRuntimeError ¶
HandleRuntimeError handles runtime errors and separates errors generated by runtime from fvm errors (e.g. environment errors)
func HasErrorCode ¶ added in v0.28.0
This returns true if the error or one of its nested errors matches the specified error code.
func Is ¶
Is is a utility function to call std error lib `Is` function for instance equality checks.
func IsALedgerFailure ¶ added in v0.21.0
IsALedgerFailure returns true if the error or any of the wrapped errors is a ledger failure
func IsAccountAccountPublicKeyNotFoundError ¶
IsAccountAccountPublicKeyNotFoundError returns true if error has this type
func IsAccountNotFoundError ¶
IsAccountNotFoundError returns true if error has this type
func IsCadenceRuntimeError ¶
func IsComputationLimitExceededError ¶ added in v0.25.2
IsComputationLimitExceededError returns true if error has this code.
func IsFailure ¶ added in v0.28.0
IsFailure returns true if the error is un-coded, or if the error contains a failure code.
func IsInvalidEnvelopeSignatureError ¶ added in v0.28.0
func IsInvalidPayloadSignatureError ¶ added in v0.28.0
func IsLedgerInteractionLimitExceededError ¶ added in v0.28.0
func IsMemoryLimitExceededError ¶ added in v0.25.2
IsMemoryLimitExceededError returns true if error has this code.
func IsOperationNotSupportedError ¶ added in v0.28.0
func IsStorageCapacityExceededError ¶ added in v0.28.0
func IsValueError ¶ added in v0.28.0
func NewCodedError ¶ added in v0.28.0
func SplitErrorTypes ¶
func SplitErrorTypes(inp error) (err CodedError, failure CodedError)
SplitErrorTypes splits the error into fatal (failures) and non-fatal errors
func WrapCodedError ¶ added in v0.28.0
Types ¶
type CodedError ¶ added in v0.28.0
func Find ¶ added in v0.28.0
func Find(err error, code ErrorCode) CodedError
This recursively unwraps the error and returns first CodedError that matches the specified error code.
func NewAccountAlreadyExistsError ¶
func NewAccountAlreadyExistsError(address flow.Address) CodedError
NewAccountAlreadyExistsError constructs a new CodedError. It is returned when account creation fails because another account already exist at that address.
TODO maybe this should be failure since user has no control over this
func NewAccountAuthorizationErrorf ¶
func NewAccountAuthorizationErrorf( address flow.Address, msg string, args ...interface{}, ) CodedError
NewAccountAuthorizationErrorf constructs a new CodedError which indicates that an authorization issue either:
- a transaction is missing a required signature to authorize access to an account, or
- a transaction doesn't have authorization to performe some operations like account creation.
func NewAccountNotFoundError ¶
func NewAccountNotFoundError(address flow.Address) CodedError
func NewAccountPublicKeyLimitError ¶ added in v0.27.0
func NewAccountPublicKeyLimitError( address flow.Address, counts uint64, limit uint64, ) CodedError
NewAccountPublicKeyLimitError constructs a new CodedError. It is returned when an account tries to add public keys over the limit.
func NewAccountPublicKeyNotFoundError ¶
func NewAccountPublicKeyNotFoundError( address flow.Address, keyIndex uint64, ) CodedError
NewAccountPublicKeyNotFoundError constructs a new CodedError. It is returned when a public key not found for the given address and key index.
func NewBlockFinderFailure ¶
func NewBlockFinderFailure(err error) CodedError
NewBlockFinderFailure constructs a new CodedError which captures a fatal caused by block finder.
func NewCadenceRuntimeError ¶
func NewCadenceRuntimeError(err runtime.Error) CodedError
NewCadenceRuntimeError constructs a new CodedError which captures a collection of errors provided by cadence runtime. It cover cadence errors such as:
NotDeclaredError, NotInvokableError, ArgumentCountError, TransactionNotDeclaredError, ConditionError, RedeclarationError, DereferenceError, OverflowError, UnderflowError, DivisionByZeroError, DestroyedCompositeError, ForceAssignmentToNonNilResourceError, ForceNilError, TypeMismatchError, InvalidPathDomainError, OverwriteError, CyclicLinkError, ArrayIndexOutOfBoundsError, ...
The Cadence error might have occurred because of an inner fvm Error.
func NewComputationLimitExceededError ¶ added in v0.25.2
func NewComputationLimitExceededError(limit uint64) CodedError
NewComputationLimitExceededError constructs a new CodedError which indicates that computation has exceeded its limit.
func NewContractNotFoundError ¶
func NewContractNotFoundError( address flow.Address, contract string, ) CodedError
NewContractNotFoundError constructs a new ErrContractNotFoundError error
func NewCouldNotGetExecutionParameterFromStateError ¶ added in v0.25.2
func NewCouldNotGetExecutionParameterFromStateError( address string, path string, ) CodedError
NewCouldNotGetExecutionParameterFromStateError constructs a new CodedError which indicates that computation has exceeded its limit.
func NewEncodingFailuref ¶
func NewEncodingFailuref( err error, msg string, args ...interface{}, ) CodedError
NewEncodingFailuref formats and returns a new EncodingFailure
func NewEventLimitExceededError ¶
func NewEventLimitExceededError( totalByteSize uint64, limit uint64) CodedError
NewEventLimitExceededError constructs a CodedError which indicates that the transaction has produced events with size more than limit.
func NewFrozenAccountError ¶
func NewFrozenAccountError(address flow.Address) CodedError
NewFrozenAccountError constructs a new FrozenAccountError
func NewInvalidAddressErrorf ¶
func NewInvalidAddressErrorf( address flow.Address, msg string, args ...interface{}, ) CodedError
NewInvalidAddressErrorf constructs a new CodedError which indicates that a transaction references an invalid flow Address in either the Authorizers or Payer field.
func NewInvalidArgumentErrorf ¶
func NewInvalidArgumentErrorf(msg string, args ...interface{}) CodedError
NewInvalidArgumentErrorf constructs a new CodedError which indicates that a transaction includes invalid arguments. This error is the result of failure in any of the following conditions: - number of arguments doesn't match the template
TODO add more cases like argument size
func NewInvalidEnvelopeSignatureError ¶
func NewInvalidEnvelopeSignatureError( txnSig flow.TransactionSignature, err error, ) CodedError
NewInvalidEnvelopeSignatureError constructs a new CodedError which indicates that signature verification for a envelope key in this transaction has failed. Tthis error is the result of failure in any of the following conditions: - provided hashing method is not supported - signature size or format is invalid - signature verification failed
func NewInvalidLocationErrorf ¶
func NewInvalidLocationErrorf( location runtime.Location, msg string, args ...interface{}, ) CodedError
NewInvalidLocationErrorf constructs a new CodedError which indicates an invalid location is passed.
func NewInvalidPayloadSignatureError ¶
func NewInvalidPayloadSignatureError( txnSig flow.TransactionSignature, err error, ) CodedError
NewInvalidPayloadSignatureError constructs a new CodedError which indicates that signature verification for a key in this transaction has failed. This error is the result of failure in any of the following conditions: - provided hashing method is not supported - signature size or format is invalid - signature verification failed
func NewInvalidProposalSeqNumberError ¶
func NewInvalidProposalSeqNumberError( proposal flow.ProposalKey, currentSeqNumber uint64, ) CodedError
NewInvalidProposalSeqNumberError constructs a new InvalidProposalSeqNumberError
func NewInvalidProposalSignatureError ¶
func NewInvalidProposalSignatureError( proposal flow.ProposalKey, err error, ) CodedError
NewInvalidProposalSignatureError constructs a new CodedError which indicates that no valid signature is provided for the proposal key.
func NewLedgerFailure ¶
func NewLedgerFailure(err error) CodedError
NewLedgerFailure constructs a new CodedError which captures a fatal error cause by ledger failures.
func NewLedgerInteractionLimitExceededError ¶ added in v0.27.0
func NewLedgerInteractionLimitExceededError( used uint64, limit uint64, ) CodedError
NewLedgerInteractionLimitExceededError constructs a CodeError. It is returned when a tx hits the maximum ledger interaction limit.
func NewMemoryLimitExceededError ¶ added in v0.25.2
func NewMemoryLimitExceededError(limit uint64) CodedError
NewMemoryLimitExceededError constructs a new CodedError which indicates that execution has exceeded its memory limits.
func NewOperationAuthorizationErrorf ¶
func NewOperationAuthorizationErrorf( operation string, msg string, args ...interface{}, ) CodedError
NewOperationAuthorizationErrorf constructs a new CodedError which indicates not enough authorization to perform an operations like account creation or smart contract deployment.
func NewOperationNotSupportedError ¶
func NewOperationNotSupportedError(operation string) CodedError
NewOperationNotSupportedError construct a new CodedError. It is generated when an operation (e.g. getting block info) is not supported in the current environment.
func NewParseRestrictedModeInvalidAccessFailure ¶ added in v0.28.0
func NewParseRestrictedModeInvalidAccessFailure(op string) CodedError
NewParseRestrictedModeInvalidAccessFailure constructs a CodedError which captures a fatal caused by Cadence accessing an unexpected environment operation while it is parsing programs.
func NewScriptExecutionCancelledError ¶ added in v0.26.0
func NewScriptExecutionCancelledError(err error) CodedError
NewScriptExecutionCancelledError construct a new CodedError which indicates that Cadence Script execution has been cancelled (e.g. request connection has been droped)
note: this error is used by scripts only and won't be emitted for transactions since transaction execution has to be deterministic.
func NewScriptExecutionTimedOutError ¶ added in v0.26.0
func NewScriptExecutionTimedOutError() CodedError
NewScriptExecutionTimedOutError construct a new CodedError which indicates that Cadence Script execution has been taking more time than what is allowed.
note: this error is used by scripts only and won't be emitted for transactions since transaction execution has to be deterministic.
func NewStateKeySizeLimitError ¶
func NewStateKeySizeLimitError( owner string, key string, size uint64, limit uint64, ) CodedError
NewStateKeySizeLimitError constructs a CodedError which indicates that the provided key has exceeded the size limit allowed by the storage.
func NewStateMergeFailure ¶
func NewStateMergeFailure(err error) CodedError
NewStateMergeFailure constructs a new CodedError which captures a fatal caused by state merge.
func NewStateValueSizeLimitError ¶
func NewStateValueSizeLimitError( value flow.RegisterValue, size uint64, limit uint64, ) CodedError
NewStateValueSizeLimitError constructs a CodedError which indicates that the provided value has exceeded the size limit allowed by the storage.
func NewStorageCapacityExceededError ¶
func NewStorageCapacityExceededError( address flow.Address, storageUsed uint64, storageCapacity uint64, ) CodedError
NewStorageCapacityExceededError constructs a new CodedError which indicates that an account used more storage than it has storage capacity.
func NewTransactionFeeDeductionFailedError ¶ added in v0.17.1
func NewTransactionFeeDeductionFailedError( payer flow.Address, txFees uint64, err error, ) CodedError
NewTransactionFeeDeductionFailedError constructs a new CodedError which indicates that a there was an error deducting transaction fees from the transaction Payer
func NewUnknownFailure ¶
func NewUnknownFailure(err error) CodedError
func NewValueErrorf ¶
func NewValueErrorf( valueStr string, msg string, args ...interface{}, ) CodedError
NewValueErrorf constructs a new CodedError which indicates a value is not valid value.
type ErrorCode ¶
type ErrorCode uint16
const ( FailureCodeUnknownFailure ErrorCode = 2000 FailureCodeEncodingFailure ErrorCode = 2001 FailureCodeLedgerFailure ErrorCode = 2002 FailureCodeStateMergeFailure ErrorCode = 2003 FailureCodeBlockFinderFailure ErrorCode = 2004 // Deprecated: No longer used. FailureCodeHasherFailure ErrorCode = 2005 FailureCodeParseRestrictedModeInvalidAccessFailure ErrorCode = 2006 // Deprecated: No longer used. FailureCodeMetaTransactionFailure ErrorCode = 2100 )
const ( // tx validation errors 1000 - 1049 // Deprecated: no longer in use ErrCodeTxValidationError ErrorCode = 1000 // Deprecated: No longer used. ErrCodeInvalidTxByteSizeError ErrorCode = 1001 // Deprecated: No longer used. ErrCodeInvalidReferenceBlockError ErrorCode = 1002 // Deprecated: No longer used. ErrCodeExpiredTransactionError ErrorCode = 1003 // Deprecated: No longer used. ErrCodeInvalidScriptError ErrorCode = 1004 // Deprecated: No longer used. ErrCodeInvalidGasLimitError ErrorCode = 1005 ErrCodeInvalidProposalSignatureError ErrorCode = 1006 ErrCodeInvalidProposalSeqNumberError ErrorCode = 1007 ErrCodeInvalidPayloadSignatureError ErrorCode = 1008 ErrCodeInvalidEnvelopeSignatureError ErrorCode = 1009 // base errors 1050 - 1100 // Deprecated: No longer used. ErrCodeFVMInternalError ErrorCode = 1050 ErrCodeValueError ErrorCode = 1051 ErrCodeInvalidArgumentError ErrorCode = 1052 ErrCodeInvalidAddressError ErrorCode = 1053 ErrCodeInvalidLocationError ErrorCode = 1054 ErrCodeAccountAuthorizationError ErrorCode = 1055 ErrCodeOperationAuthorizationError ErrorCode = 1056 ErrCodeOperationNotSupportedError ErrorCode = 1057 // execution errors 1100 - 1200 // Deprecated: No longer used. ErrCodeExecutionError ErrorCode = 1100 ErrCodeCadenceRunTimeError ErrorCode = 1101 // Deprecated: No longer used. ErrCodeEncodingUnsupportedValue ErrorCode = 1102 ErrCodeStorageCapacityExceeded ErrorCode = 1103 // Deprecated: No longer used. ErrCodeGasLimitExceededError ErrorCode = 1104 ErrCodeEventLimitExceededError ErrorCode = 1105 ErrCodeLedgerInteractionLimitExceededError ErrorCode = 1106 ErrCodeStateKeySizeLimitError ErrorCode = 1107 ErrCodeStateValueSizeLimitError ErrorCode = 1108 ErrCodeTransactionFeeDeductionFailedError ErrorCode = 1109 ErrCodeComputationLimitExceededError ErrorCode = 1110 ErrCodeMemoryLimitExceededError ErrorCode = 1111 ErrCodeCouldNotDecodeExecutionParameterFromState ErrorCode = 1112 ErrCodeScriptExecutionCancelledError ErrorCode = 1114 ErrCodeScriptExecutionTimedOutError ErrorCode = 1113 // accounts errors 1200 - 1250 // Deprecated: No longer used. ErrCodeAccountError ErrorCode = 1200 ErrCodeAccountNotFoundError ErrorCode = 1201 ErrCodeAccountPublicKeyNotFoundError ErrorCode = 1202 ErrCodeAccountAlreadyExistsError ErrorCode = 1203 ErrCodeFrozenAccountError ErrorCode = 1204 // Deprecated: No longer used. ErrCodeAccountStorageNotInitializedError ErrorCode = 1205 ErrCodeAccountPublicKeyLimitError ErrorCode = 1206 // contract errors 1250 - 1300 // Deprecated: No longer used. ErrCodeContractError ErrorCode = 1250 ErrCodeContractNotFoundError ErrorCode = 1251 // Deprecated: No longer used. ErrCodeContractNamesNotFoundError ErrorCode = 1252 )
type FrozenAccountError ¶
type FrozenAccountError struct { CodedError // contains filtered or unexported fields }
FrozenAccountError is returned when a frozen account signs a transaction
func (FrozenAccountError) Address ¶
func (e FrozenAccountError) Address() flow.Address
Address returns the address of frozen account
type InvalidProposalSeqNumberError ¶
type InvalidProposalSeqNumberError struct { CodedError // contains filtered or unexported fields }
InvalidProposalSeqNumberError indicates that proposal key sequence number does not match the on-chain value.
func (InvalidProposalSeqNumberError) CurrentSeqNumber ¶
func (e InvalidProposalSeqNumberError) CurrentSeqNumber() uint64
CurrentSeqNumber returns the current sequence number
func (InvalidProposalSeqNumberError) ProvidedSeqNumber ¶ added in v0.16.0
func (e InvalidProposalSeqNumberError) ProvidedSeqNumber() uint64
ProvidedSeqNumber returns the provided sequence number