use crate::trap::RuntimeError;
use std::io;
use thiserror::Error;
use wasmer_compiler::CompileError;
use wasmer_types::ExternType;
#[derive(Error, Debug)]
pub enum SerializeError {
#[error(transparent)]
Io(#[from] io::Error),
#[error("{0}")]
Generic(String),
}
#[derive(Error, Debug)]
pub enum DeserializeError {
#[error(transparent)]
Io(#[from] io::Error),
#[error("{0}")]
Generic(String),
#[error("incompatible binary: {0}")]
Incompatible(String),
#[error("corrupted binary: {0}")]
CorruptedBinary(String),
#[error(transparent)]
Compiler(CompileError),
}
#[derive(Error, Debug)]
pub enum ImportError {
#[error("incompatible import type. Expected {0:?} but received {1:?}")]
IncompatibleType(ExternType, ExternType),
#[error("unknown import. Expected {0:?}")]
UnknownImport(ExternType),
}
#[derive(Error, Debug)]
#[error("Link error: {0}")]
pub enum LinkError {
#[error("Error while importing {0:?}.{1:?}: {2}")]
Import(String, String, ImportError),
#[error("RuntimeError occurred during linking: {0}")]
Trap(#[source] RuntimeError),
#[error("Insufficient resources: {0}")]
Resource(String),
}
#[derive(Error, Debug)]
pub enum InstantiationError {
#[error(transparent)]
Link(LinkError),
#[error(transparent)]
Start(RuntimeError),
}