1use crate::HostImportError;
18use crate::misc::PrepareError;
19
20use marine_it_interfaces::MITInterfacesError;
21use marine_it_parser::ITParserError;
22use marine_module_interface::it_interface::ITInterfaceError;
23use marine_wasm_backend_traits::errors::*;
24
25use thiserror::Error as ThisError;
26
27#[derive(Debug, ThisError)]
31pub enum MError {
32 #[error("{0}")]
34 RecordResolveError(String), #[error(transparent)]
38 WASIPrepareError(#[from] WasiError),
39
40 #[error(transparent)]
42 ModuleInterfaceError(#[from] ITInterfaceError),
43
44 #[error("Execution error: {0}")]
46 ITInstructionError(#[from] wasmer_it::errors::InstructionError),
47
48 #[error(transparent)]
50 PrepareError(#[from] PrepareError),
51
52 #[error("module with name '{0}' already loaded into Marine, please specify another name")]
54 NonUniqueModuleName(String),
55
56 #[error("module with name '{0}' doesn't have function with name {1}")]
58 NoSuchFunction(String, String),
59
60 #[error("module with name '{0}' isn't loaded into Marine")]
62 NoSuchModule(String),
63
64 #[error(transparent)]
66 HostImportError(#[from] HostImportError),
67
68 #[error(transparent)]
70 WITParseError(#[from] ITParserError),
71
72 #[error("{0}")]
74 IncorrectWIT(String), #[error("Wasm backend error: {0}")]
77 WasmBackendError(#[from] WasmBackendError),
78}
79
80impl From<MITInterfacesError> for MError {
81 fn from(err: MITInterfacesError) -> Self {
82 MError::IncorrectWIT(format!("{}", err))
83 }
84}
85
86impl From<ModuleCreationError> for MError {
87 fn from(value: ModuleCreationError) -> Self {
88 Into::<WasmBackendError>::into(value).into()
89 }
90}
91
92impl From<ResolveError> for MError {
93 fn from(value: ResolveError) -> Self {
94 Into::<WasmBackendError>::into(value).into()
95 }
96}
97
98impl From<ImportError> for MError {
99 fn from(value: ImportError) -> Self {
100 Into::<WasmBackendError>::into(value).into()
101 }
102}
103
104impl From<InstantiationError> for MError {
105 fn from(value: InstantiationError) -> Self {
106 Into::<WasmBackendError>::into(value).into()
107 }
108}
109
110impl From<RuntimeError> for MError {
111 fn from(value: RuntimeError) -> Self {
112 Into::<WasmBackendError>::into(value).into()
113 }
114}