1use pallet_revive::evm::CallTrace;
16use std::fmt;
17
18#[derive(Debug, thiserror::Error)]
24pub enum Error<DispatchError: fmt::Debug + fmt::Display> {
25 #[error("Contract not found: {0}")]
27 ContractNotFound(String),
28 #[error("Instantiate dry-run error: {0}")]
30 InstantiateDryRun(DryRunError<DispatchError>),
31 #[error("Instantiate extrinsic error: {0} {1:?}")]
32 InstantiateExtrinsic(DispatchError, Option<CallTrace>),
33 #[error("Upload dry-run error: {0}")]
35 UploadDryRun(DispatchError),
36 #[error("Upload extrinsic error: {0}")]
38 UploadExtrinsic(DispatchError, Option<CallTrace>),
39 #[error("Call dry-run error: {0}")]
41 CallDryRun(DryRunError<DispatchError>),
42 #[error("Call extrinsic error: {0}")]
44 CallExtrinsic(DispatchError, Option<CallTrace>),
45 #[error("Remove code extrinsic error: {0}")]
47 RemoveCodeExtrinsic(DispatchError, Option<CallTrace>),
48 #[error("Fetching account Balance error: {0}")]
50 Balance(String),
51 #[error("Decoding failed: {0}")]
53 Decoding(String),
54 #[error("Other error: {0}")]
56 Other(String),
57}
58
59#[derive(Debug)]
61pub struct DryRunError<DispatchError: fmt::Display + fmt::Debug> {
62 pub error: DispatchError,
63}
64
65impl<DispatchError> fmt::Display for DryRunError<DispatchError>
66where
67 DispatchError: fmt::Display + fmt::Debug,
68{
69 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
70 <Self as fmt::Debug>::fmt(self, f)
71 }
72}
73
74#[derive(Debug, thiserror::Error)]
76pub struct SandboxErr {
77 msg: String,
78}
79
80impl SandboxErr {
81 #[allow(dead_code)]
83 pub fn new(msg: String) -> Self {
84 Self { msg }
85 }
86}
87
88impl From<String> for SandboxErr {
89 fn from(msg: String) -> Self {
90 Self { msg }
91 }
92}
93
94impl fmt::Display for SandboxErr {
95 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
96 write!(f, "SandboxErr: {}", self.msg)
97 }
98}