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}")]
44 CallExtrinsic(DispatchError),
45 #[error("Remove code extrinsic error: {0}")]
47 RemoveCodeExtrinsic(DispatchError),
48 #[error("Fetching account Balance error: {0}")]
50 Balance(String),
51 #[error("Decoding failed: {0}")]
53 Decoding(String),
54}
55
56#[derive(Debug)]
58pub struct DryRunError<DispatchError: fmt::Display + fmt::Debug> {
59 pub error: DispatchError,
60}
61
62impl<DispatchError> fmt::Display for DryRunError<DispatchError>
63where
64 DispatchError: fmt::Display + fmt::Debug,
65{
66 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
67 <Self as fmt::Debug>::fmt(self, f)
68 }
69}
70
71#[derive(Debug, thiserror::Error)]
73pub struct SandboxErr {
74 msg: String,
75}
76
77impl SandboxErr {
78 #[allow(dead_code)]
80 pub fn new(msg: String) -> Self {
81 Self { msg }
82 }
83}
84
85impl From<String> for SandboxErr {
86 fn from(msg: String) -> Self {
87 Self { msg }
88 }
89}
90
91impl fmt::Display for SandboxErr {
92 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
93 write!(f, "SandboxErr: {}", self.msg)
94 }
95}