ac_node_api/metadata/error.rs
1/*
2 Copyright 2021 Supercomputing Systems AG
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 http://www.apache.org/licenses/LICENSE-2.0
7 Unless required by applicable law or agreed to in writing, software
8 distributed under the License is distributed on an "AS IS" BASIS,
9 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 See the License for the specific language governing permissions and
11 limitations under the License.
12*/
13
14use alloc::string::String;
15use codec::{Decode, Encode};
16
17/// Metadata error originated from inspecting the internal representation of the runtime metadata.
18#[derive(Debug, Clone, PartialEq, Eq)]
19pub enum MetadataError {
20 /// The DispatchError type isn't available in the metadata.
21 DispatchErrorNotFound,
22 /// Module is not in metadata.
23 PalletNameNotFound(String),
24 /// Pallet is not in metadata.
25 PalletIndexNotFound(u8),
26 /// Event type not found in metadata.
27 EventTypeNotFoundInPallet(u8),
28 /// Call is not in metadata.
29 CallNotFound(&'static str),
30 /// Event is not in metadata.
31 EventNotFound(u8, u8),
32 /// Error is not in metadata.
33 ErrorNotFound(u8, u8),
34 /// Storage is not in metadata.
35 StorageNotFound(&'static str),
36 /// Storage type does not match requested type.
37 StorageTypeError,
38 /// Constant is not in metadata.
39 ConstantNotFound(&'static str),
40 /// Variant not found.
41 VariantIndexNotFound(u8),
42 /// Api is not in metadata.
43 RuntimeApiNotFound(String),
44 /// Exptected a different type of Metadata. Has there been a runtime upgrade inbetween?
45 MetadataMismatch,
46}
47
48#[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Encode, Decode)]
49pub enum MetadataConversionError {
50 InvalidPrefix,
51 InvalidVersion,
52 /// Type is missing from type registry.
53 MissingType(u32),
54 /// Type was not variant/enum type.
55 TypeDefNotVariant(u32),
56 /// Type is not in metadata.
57 TypeNotFound(u32),
58 /// Type Name is not in metadata.
59 TypeNameNotFound(String),
60 // Path not found.
61 InvalidTypePath(String),
62}