DispatchError

Variant 26 v393

sp_runtime::DispatchError

About This Type

Top-level error type returned when an extrinsic fails.

Wraps all possible error sources: module errors (from pallets), token errors, arithmetic errors, and transactional errors. The first step in decoding why a transaction failed.

Encoding: Variant type: 1-byte index selects the error category, followed by category-specific data.

Common Uses

  • • Decode failed extrinsics to determine the error cause
  • • Build error handling in applications
  • • Display user-friendly error messages

Variants (15)

IndexNameFieldsDocs
0Othernone
1CannotLookupnone
2BadOriginnone
3Module
4ConsumerRemainingnone
5NoProvidersnone
6TooManyConsumersnone
7Token
8Arithmetic
9Transactional
10Exhaustednone
11Corruptionnone
12Unavailablenone
13RootNotAllowednone
14Trie

SCALE Encoding

Rule
1-byte variant index selects the error category, followed by category-specific data.
Size
variable (1+ bytes)

Examples

Module error (pallet 8, error 3) = Module { index: 8, error: [3, 0, 0, 0] }
0x030803000000
03 Variant index 3 = Module
08 Pallet index 8
03 00 00 00 Error bytes (first byte = error index 3)

Code Examples

import { TypeRegistry } from "@polkadot/types";

const registry = new TypeRegistry();

// Encode DispatchError — variant "Other"
const value = registry.createType("DispatchError", "Other");
console.log("Hex:", value.toHex());

Referenced By (12)

Also See

Type Information

Type ID
26
Kind
Variant
Path
sp_runtime::DispatchError
Runtime
v393