1use ceres_std::{String, Vec};
3
4#[derive(Debug)]
6pub enum Error {
7 OutOfBounds,
9 DecodeRuntimeValueFailed,
11 OutputBufferTooSmall,
13 ReturnData {
14 flags: u32,
15 data: Vec<u8>,
16 },
17 ParseWasmModuleFailed,
19 ParseNameSectionFailed {
21 error: String,
22 },
23 CalcuateMemoryLimitFailed,
25 AllocMemoryFailed,
27 SerializeFailed {
28 error: parity_wasm::SerializationError,
29 },
30 InitModuleFailed {
32 error: ceres_executor::Error,
33 },
34 DeployContractFailed {
36 error: ceres_executor::Error,
37 },
38 CallContractFailed {
39 error: ceres_executor::Error,
40 },
41 DecodeSelectorFailed,
43 DecodeContractFailed,
45 InvalidArgumentLength {
47 expect: usize,
48 input: usize,
49 },
50 DecodeArgumentFailed {
52 arg: Vec<u8>,
53 },
54 GetMethodFailed {
55 name: String,
56 },
57 CouldNotSetStorage,
59 GetStorageFailed,
61 InvalidCodeHash,
63 Custom(&'static str),
64 InsertContractFailed,
66 GetContractFailed,
68 SerdeError,
70 ExecutorNotInited,
71 InitExecutorFailed,
72 ExecuteWasmFailed(ceres_executor::Error),
74 LoadDataFailed,
75 FlushDataFailed,
76}
77
78impl From<ceres_executor::Error> for Error {
79 fn from(e: ceres_executor::Error) -> Error {
80 Error::ExecuteWasmFailed(e)
81 }
82}
83
84impl From<&'static str> for Error {
85 fn from(e: &'static str) -> Error {
86 Error::Custom(e)
87 }
88}
89
90impl PartialEq for Error {
91 fn eq(&self, other: &Self) -> bool {
92 match self {
93 Error::SerializeFailed { error: _ } => false,
94 _ => self.eq(other),
95 }
96 }
97}
98
99impl Eq for Error {}
100
101pub type Result<T> = core::result::Result<T, Error>;