use marine_module_interface::interface::InterfaceError;
use marine_module_interface::it_interface::ITInterfaceError;
use wasmer_it::decoders::wat::Error as WATError;
use thiserror::Error as ThisError;
use std::io::Error as IOError;
#[derive(Debug, ThisError)]
pub enum ITParserError {
#[error("the module doesn't contain IT section")]
NoITSection,
#[error("the module contains multiple IT sections that is unsupported")]
MultipleITSections,
#[error("IT section is corrupted: IT section remainder isn't empty")]
ITRemainderNotEmpty,
#[error(
"IT section is corrupted: {0}.\
\nProbably the module was compiled with an old version of marine cli, please try to update and recompile.\
\nTo update marine run: cargo install marine --force"
)]
CorruptedITSection(nom::Err<(Vec<u8>, nom::error::ErrorKind)>),
#[error("{0}")]
IncorrectITFormat(String),
#[error("{0}")]
ModuleInterfaceError(#[from] InterfaceError),
#[error("{0}")]
ModuleITInterfaceError(#[from] ITInterfaceError),
#[error("provided file with IT definitions is corrupted: {0}")]
CorruptedITFile(#[from] WATError),
#[error("provided Wasm file is corrupted: {0}")]
CorruptedWasmFile(anyhow::Error),
#[error("Convertation Wast to AST failed with: {0}")]
AstToBytesError(#[from] IOError),
#[error("Emitting resulted Wasm file failed with: {0}")]
WasmEmitError(anyhow::Error),
}