Skip to content

Commit

Permalink
Merge pull request #100 from onflow/error-codes-documentation
Browse files Browse the repository at this point in the history
Error codes documentation
  • Loading branch information
lealobanov authored Oct 3, 2024
2 parents 7d844d7 + 447f37a commit e146c6b
Show file tree
Hide file tree
Showing 2 changed files with 203 additions and 0 deletions.
169 changes: 169 additions & 0 deletions ERROR_CODES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Error Codes

This file documents the list of error code returned from failing transactions and scripts in the SDK. Each error code has an accompanying error message that provides more clarification as to the nature of the error thrown.

The associated code file for these error codes can be found [here](sdk/src/main/kotlin/org/onflow/flow/sdk/errors.kt).

## Table of Contents
- [Transaction Validation Errors](#transaction-validation-errors-1000---1049)
- [Base Errors](#base-errors-1050---1099)
- [Execution Errors](#execution-errors-1100---1199)
- [Accounts Errors](#accounts-errors-1200---1249)
- [Contracts Errors](#contract-errors-1250---1299)


## Transaction Validation Errors (1000 - 1049)

### [DEPRECATED] 1000: TxValidationError

### [DEPRECATED] 1001: InvalidTxByteSizeError

### [DEPRECATED] 1002: InvalidReferenceBlockError

### [DEPRECATED] 1003: ExpiredTransactionError

### [DEPRECATED] 1004: InvalidScriptError

### [DEPRECATED] 1005: InvalidGasLimitError

### 1006: InvalidProposalSignatureError
```bash
[Error Code: 1006] invalid proposal signature: public key 0 on account xxx does not have a valid signature: signature is not valid
```

### 1007: InvalidProposalSeqNumberError
```bash
[Error Code: 1007] invalid proposal key: public key 0 on account xxx has sequence number xxx, but given xxx
```

### 1008: InvalidPayloadSignatureError
```bash
[Error Code: 1008] invalid payload signature: public key 0 on account xxx does not have a valid signature: signature is not valid
```

### 1009: InvalidEnvelopeSignatureError
```bash
[Error Code: 1009] invalid envelope key: public key 1 on account xxx does not have a valid signature: signature is not valid
```

## Base Errors (1050 - 1099)

### [DEPRECATED] 1050: FVMInternalError

### 1051: ValueError
```bash
[Error Code: 1051] invalid value (xxx): invalid encoded public key value: rlp: expected input list for flow.runtimeAccountPublicKeyWrapper...
```

### 1052: InvalidArgumentError
```bash
[Error Code: 1052] transaction arguments are invalid: (argument is not json decodable: failed to decode value: runtime error: slice bounds out of range [:2] with length 0)
```

### 1053: InvalidAddressError

### 1054: InvalidLocationError
```bash
[Error Code: 1054] location (../contracts/FungibleToken.cdc) is not a valid location: expecting an AddressLocation, but other location types are passed ../contracts/FungibleToken.cdc
```

### 1055: AccountAuthorizationError
```bash
[Error Code: 1055] authorization failed for account e85d442d61a611d8: payer account does not have sufficient signatures (1 < 1000)
```

### 1056: OperationAuthorizationError
```bash
[Error Code: 1056] (RemoveContract) is not authorized: removing contracts requires authorization from specific accounts goroutine 5688834491 [running]:
```

### 1057: OperationNotSupportedError

### 1058: BlockHeightOutOfRangeError

## Execution Errors (1100 - 1199)

### [DEPRECATED] 1100: CodeExecutionError

### 1101: CadenceRunTimeError
```bash
[Error Code: 1101] cadence runtime error Execution failed: error: pre-condition failed: Amount withdrawn must be less than or equal than the balance of the Vault
```

### [DEPRECATED] 1102: EncodingUnsupportedValue

### 1103: StorageCapacityExceeded
```bash
[Error Code: 1103] The account with address (xxx) uses 96559611 bytes of storage which is over its capacity (96554500 bytes). Capacity can be increased by adding FLOW tokens to the account.
```

### [DEPRECATED] 1104: GasLimitExceededError

### 1105: EventLimitExceededError
```bash
[Error Code: 1105] total event byte size (256200) exceeds limit (256000)
```

### 1106: LedgerIntractionLimitExceededError
```bash
[Error Code: 1106] max interaction with storage has exceeded the limit (used: 20276498 bytes, limit 20000000 bytes)
```

### 1107: StateKeySizeLimitError

### 1108: StateValueSizeLimitError

### 1109: TransactionFeeDeductionFailedError
```bash
[Error Code: 1109] failed to deduct 0 transaction fees from 14af75b8c487333c: Execution failed: f919ee77447b7497.FlowFees:97:24
```

### 1110: ComputationLimitExceededError
```bash
[Error Code: 1110] computation exceeds limit (100)
```

### 1111: MemoryLimitExceededError

### 1112: CouldNotDecodeExecutionParameterFromState

### 1113: ScriptExecutionTimedOutError

### 1114: ScriptExecutionCancelledError

### 1115: EventEncodingError

### 1116: InvalidInternalStateAccessError

### 1118: InsufficientPayerBalance
```bash
[Error Code: 1118] payer ... has insufficient balance to attempt transaction execution (required balance: 0.00100000)
```

## Accounts Errors (1200 - 1249)

### 1201: AccountNotFoundError
```bash
[Error Code: 1201] account not found for address xxx
```

### 1202: AccountPublicKeyNotFoundError
```bash
[Error Code: 1202] account public key not found for address xxx and key index 3
```

### 1203: AccountAlreadyExistsError

### [DEPRECATED] 1204: FrozenAccountError

### [DEPRECATED] 1205: AccountStorageNotInitializedError

### 1206: AccountPublicKeyLimitError

## Contract Errors (1250 - 1299)

### [DEPRECATED] 1250: ContractError

### 1251: ContractNotFoundError

### [DEPRECATED] 1252: ContractNamesNotFoundError
34 changes: 34 additions & 0 deletions sdk/src/main/kotlin/org/onflow/flow/sdk/errors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ fun parseErrorCode(message: String): Int? = message
?.toIntOrNull()

enum class FlowError(val code: Int) {
@Deprecated("No longer in use.")
FLOW_ERROR_InvalidTxByteSizeError(FlowErrorCodeInvalidTxByteSizeError),
@Deprecated("No longer in use.")
FLOW_ERROR_InvalidReferenceBlockError(FlowErrorCodeInvalidReferenceBlockError),
@Deprecated("No longer in use.")
FLOW_ERROR_ExpiredTransactionError(FlowErrorCodeExpiredTransactionError),
@Deprecated("No longer in use.")
FLOW_ERROR_InvalidScriptError(FlowErrorCodeInvalidScriptError),
@Deprecated("No longer in use.")
FLOW_ERROR_InvalidGasLimitError(FlowErrorCodeInvalidGasLimitError),
FLOW_ERROR_InvalidProposalSignatureError(FlowErrorCodeInvalidProposalSignatureError),
FLOW_ERROR_InvalidProposalSeqNumberError(FlowErrorCodeInvalidProposalSeqNumberError),
FLOW_ERROR_InvalidPayloadSignatureError(FlowErrorCodeInvalidPayloadSignatureError),
FLOW_ERROR_InvalidEnvelopeSignatureError(FlowErrorCodeInvalidEnvelopeSignatureError),

@Deprecated("No longer in use.")
FLOW_ERROR_FVMInternalError(FlowErrorCodeFVMInternalError),
FLOW_ERROR_ValueError(FlowErrorCodeValueError),
FLOW_ERROR_InvalidArgumentError(FlowErrorCodeInvalidArgumentError),
Expand All @@ -26,23 +32,38 @@ enum class FlowError(val code: Int) {
FLOW_ERROR_AccountAuthorizationError(FlowErrorCodeAccountAuthorizationError),
FLOW_ERROR_OperationAuthorizationError(FlowErrorCodeOperationAuthorizationError),
FLOW_ERROR_OperationNotSupportedError(FlowErrorCodeOperationNotSupportedError),
FLOW_ERROR_FBlockHeightOutOfRangeError(FlowErrorCodeBlockHeightOutOfRangeError),

FLOW_ERROR_CadenceRunTimeError(FlowErrorCodeCadenceRunTimeError),
@Deprecated("No longer in use.")
FLOW_ERROR_EncodingUnsupportedValue(FlowErrorCodeEncodingUnsupportedValue),
FLOW_ERROR_StorageCapacityExceeded(FlowErrorCodeStorageCapacityExceeded),
@Deprecated("No longer in use.")
FLOW_ERROR_GasLimitExceededError(FlowErrorCodeGasLimitExceededError),
FLOW_ERROR_EventLimitExceededError(FlowErrorCodeEventLimitExceededError),
FLOW_ERROR_LedgerIntractionLimitExceededError(FlowErrorCodeLedgerIntractionLimitExceededError),
FLOW_ERROR_StateKeySizeLimitError(FlowErrorCodeStateKeySizeLimitError),
FLOW_ERROR_StateValueSizeLimitError(FlowErrorCodeStateValueSizeLimitError),
FLOW_ERROR_TransactionFeeDeductionFailedError(FlowErrorCodeTransactionFeeDeductionFailedError),
FLOW_ERROR_ComputationLimitExceededError(FlowErrorCodeComputationLimitExceededError),
FLOW_ERROR_MemoryLimitExceededError(FlowErrorCodeMemoryLimitExceededError),
FLOW_ERROR_CouldNotDecodeExecutionParameterFromState(FlowErrorCodeCouldNotDecodeExecutionParameterFromState),
FLOW_ERROR_ScriptExecutionTimedOutError(FlowErrorCodeScriptExecutionTimedOutError),
FLOW_ERROR_EventEncodingErrorError(FlowErrorCodeEventEncodingError),
FLOW_ERROR_InvalidInternalStateAccessError(FlowErrorCodeInvalidInternalStateAccessError),
FLOW_ERROR_InsufficientPayerBalanceError(FlowErrorCodeInsufficientPayerBalance),

FLOW_ERROR_AccountNotFoundError(FlowErrorCodeAccountNotFoundError),
FLOW_ERROR_AccountPublicKeyNotFoundError(FlowErrorCodeAccountPublicKeyNotFoundError),
FLOW_ERROR_AccountAlreadyExistsError(FlowErrorCodeAccountAlreadyExistsError),
@Deprecated("No longer in use.")
FLOW_ERROR_FrozenAccountError(FlowErrorCodeFrozenAccountError),
@Deprecated("No longer in use.")
FLOW_ERROR_AccountStorageNotInitializedError(FlowErrorCodeAccountStorageNotInitializedError),
FLOW_ERROR_AccountPublicKeyLimitError(FlowErrorCodeAccountPublicKeyLimitError),

FLOW_ERROR_ContractNotFoundError(FlowErrorCodeContractNotFoundError),
@Deprecated("No longer in use.")
FLOW_ERROR_ContractNamesNotFoundError(FlowErrorCodeContractNamesNotFoundError)
;

Expand Down Expand Up @@ -74,6 +95,7 @@ const val FlowErrorCodeInvalidLocationError: Int = 1054
const val FlowErrorCodeAccountAuthorizationError: Int = 1055
const val FlowErrorCodeOperationAuthorizationError: Int = 1056
const val FlowErrorCodeOperationNotSupportedError: Int = 1057
const val FlowErrorCodeBlockHeightOutOfRangeError: Int = 1058

// execution errors 1100 - 1200
// const val FlowErrorCodeExecutionError: Int = 1100 - reserved
Expand All @@ -86,13 +108,25 @@ const val FlowErrorCodeLedgerIntractionLimitExceededError: Int = 1106
const val FlowErrorCodeStateKeySizeLimitError: Int = 1107
const val FlowErrorCodeStateValueSizeLimitError: Int = 1108
const val FlowErrorCodeTransactionFeeDeductionFailedError: Int = 1109
const val FlowErrorCodeComputationLimitExceededError: Int = 1110
const val FlowErrorCodeMemoryLimitExceededError: Int = 1111
const val FlowErrorCodeCouldNotDecodeExecutionParameterFromState: Int = 1112
const val FlowErrorCodeScriptExecutionTimedOutError: Int = 1113
const val FlowErrorCodeScriptExecutionCancelledError: Int = 1114
const val FlowErrorCodeEventEncodingError: Int = 1115
const val FlowErrorCodeInvalidInternalStateAccessError: Int = 1116
// 1117 was never deployed and is free to use

const val FlowErrorCodeInsufficientPayerBalance: Int = 1118

// accounts errors 1200 - 1250
// const val FlowErrorCodeAccountError: Int = 1200 - reserved
const val FlowErrorCodeAccountNotFoundError: Int = 1201
const val FlowErrorCodeAccountPublicKeyNotFoundError: Int = 1202
const val FlowErrorCodeAccountAlreadyExistsError: Int = 1203
const val FlowErrorCodeFrozenAccountError: Int = 1204
const val FlowErrorCodeAccountStorageNotInitializedError: Int = 1205
const val FlowErrorCodeAccountPublicKeyLimitError: Int = 1206

// contract errors 1250 - 1300
// const val FlowErrorCodeContractError: Int = 1250 - reserved
Expand Down

0 comments on commit e146c6b

Please sign in to comment.