DispatchError
Variant 26 v393sp_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)
| Index | Name | Fields | Docs |
|---|---|---|---|
| 0 | Other | none | |
| 1 | CannotLookup | none | |
| 2 | BadOrigin | none | |
| 3 | Module | ||
| 4 | ConsumerRemaining | none | |
| 5 | NoProviders | none | |
| 6 | TooManyConsumers | none | |
| 7 | Token | ||
| 8 | Arithmetic | ||
| 9 | Transactional | ||
| 10 | Exhausted | none | |
| 11 | Corruption | none | |
| 12 | Unavailable | none | |
| 13 | RootNotAllowed | none | |
| 14 | Trie |
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] }
0x03080300000003 Variant index 3 = Module08 Pallet index 803 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)
#22 System::Event via ExtrinsicFailed.dispatch_error#22 System::Event via RejectedInvalidAuthorizedUpgrade.error#39 SubtensorModule::Event via BatchWeightItemFailed#42 Result via Err#56 Utility::Event via BatchInterrupted.error#56 Utility::Event via ItemFailed.error#56 Utility::Event via IfElseFallbackCalled.main_error#599 Result via Err#605 Result via Err#614 Result via Err#622 Result via Err#624 Result via Err
Also See
Type Information
- Type ID
- 26
- Kind
- Variant
- Path
- sp_runtime::DispatchError
- Runtime
- v393