1use std::fmt;
16
17#[derive(Debug, thiserror::Error)]
23pub enum Error<DispatchError: fmt::Debug + fmt::Display> {
24 #[error("Contract not found: {0}")]
26 ContractNotFound(String),
27 #[error("Instantiate dry-run error: {0}")]
29 InstantiateDryRun(DryRunError<DispatchError>),
30 #[error("Instantiate extrinsic error: {0}")]
31 InstantiateExtrinsic(DispatchError),
32 #[error("Upload dry-run error: {0}")]
34 UploadDryRun(DispatchError),
35 #[error("Upload extrinsic error: {0}")]
37 UploadExtrinsic(DispatchError),
38 #[error("Call dry-run error: {0}")]
40 CallDryRun(DryRunError<DispatchError>),
41 #[error("Call extrinsic error: {0}")]
43 CallExtrinsic(DispatchError),
44 #[error("Remove code extrinsic error: {0}")]
46 RemoveCodeExtrinsic(DispatchError),
47 #[error("Fetching account Balance error: {0}")]
49 Balance(String),
50 #[error("Decoding failed: {0}")]
52 Decoding(String),
53 #[error("Other error: {0}")]
55 Other(String),
56}
57
58#[derive(Debug)]
60pub struct DryRunError<DispatchError: fmt::Display + fmt::Debug> {
61 pub error: DispatchError,
62}
63
64impl<DispatchError> fmt::Display for DryRunError<DispatchError>
65where
66 DispatchError: fmt::Display + fmt::Debug,
67{
68 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
69 <Self as fmt::Debug>::fmt(self, f)
70 }
71}
72
73#[derive(Debug, thiserror::Error)]
75pub struct SandboxErr {
76 msg: String,
77}
78
79impl SandboxErr {
80 #[allow(dead_code)]
82 pub fn new(msg: String) -> Self {
83 Self { msg }
84 }
85}
86
87impl From<String> for SandboxErr {
88 fn from(msg: String) -> Self {
89 Self { msg }
90 }
91}
92
93impl fmt::Display for SandboxErr {
94 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
95 write!(f, "SandboxErr: {}", self.msg)
96 }
97}