use wasmer_wit::decoders::wat::Error as WATError;
use thiserror::Error as ThisError;
use std::io::Error as IOError;
#[derive(Debug, ThisError)]
pub enum WITParserError {
#[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 fce cli, please try to update and recompile.\
\nTo update fce run: cargo install fcli --force"
)]
CorruptedITSection(nom::Err<(Vec<u8>, nom::error::ErrorKind)>),
#[error("{0}")]
IncorrectITFormat(String),
#[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),
}