iota_package_resolver/
error.rs

1// Copyright (c) Mysten Labs, Inc.
2// Modifications Copyright (c) 2024 IOTA Stiftung
3// SPDX-License-Identifier: Apache-2.0
4
5use std::sync::Arc;
6
7use iota_types::TypeTag;
8use move_binary_format::errors::VMError;
9use move_core_types::account_address::AccountAddress;
10use thiserror::Error;
11
12#[derive(Error, Debug, Clone)]
13pub enum Error {
14    #[error("{0}")]
15    Bcs(#[from] bcs::Error),
16
17    #[error("Store {} error: {}", store, source)]
18    Store {
19        store: &'static str,
20        source: Arc<dyn std::error::Error + Send + Sync + 'static>,
21    },
22
23    #[error("{0}")]
24    Deserialize(VMError),
25
26    #[error("Package has no modules: {0}")]
27    EmptyPackage(AccountAddress),
28
29    #[error("Function not found: {0}::{1}::{2}")]
30    FunctionNotFound(AccountAddress, String, String),
31
32    #[error(
33        "Conflicting types for input {0}: {} and {}",
34        .1.to_canonical_display(/* with_prefix */ true),
35        .2.to_canonical_display(/* with_prefix */ true),
36    )]
37    InputTypeConflict(u16, TypeTag, TypeTag),
38
39    #[error("Linkage not found for package: {0}")]
40    LinkageNotFound(AccountAddress),
41
42    #[error("Module not found: {0}::{1}")]
43    ModuleNotFound(AccountAddress, String),
44
45    #[error("No origin package found for {0}::{1}::{2}")]
46    NoTypeOrigin(AccountAddress, String, String),
47
48    #[error("Not a package: {0}")]
49    NotAPackage(AccountAddress),
50
51    #[error("Not an identifier: '{0}'")]
52    NotAnIdentifier(String),
53
54    #[error("Package not found: {0}")]
55    PackageNotFound(AccountAddress),
56
57    #[error("Datatype not found: {0}::{1}::{2}")]
58    DatatypeNotFound(AccountAddress, String, String),
59
60    #[error("More than {0} struct definitions required to resolve type")]
61    TooManyTypeNodes(usize, usize),
62
63    #[error("Expected at most {0} type parameters, got {1}")]
64    TooManyTypeParams(usize, usize),
65
66    #[error("Expected {0} type parameters, but got {1}")]
67    TypeArityMismatch(usize, usize),
68
69    #[error("Type parameter nesting exceeded limit of {0}")]
70    TypeParamNesting(usize, usize),
71
72    #[error("Type Parameter {0} out of bounds ({1})")]
73    TypeParamOOB(u16, usize),
74
75    #[error("Unexpected reference type.")]
76    UnexpectedReference,
77
78    #[error("Unexpected type: 'signer'.")]
79    UnexpectedSigner,
80
81    #[error("Unexpected error: {0}")]
82    Unexpected(Arc<dyn std::error::Error + Send + Sync + 'static>),
83
84    #[error("Type layout nesting exceeded limit of {0}")]
85    ValueNesting(usize),
86}