use std::path::PathBuf;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("Failed to initialize WebAssembly runtime: {0}")]
RuntimeInitialization(String),
#[error("Failed to load WASM module: {0}")]
ModuleLoad(String),
#[error("Failed to create WASM instance: {0}")]
InstanceCreation(String),
#[error("Failed to call function '{function_name}': {reason}")]
FunctionCall {
function_name: String,
reason: String,
},
#[error("Capability error: {0}")]
Capability(String),
#[error("Resource limit error: {0}")]
ResourceLimit(String),
#[error("Communication error: {0}")]
Communication(String),
#[error("Wrapper generation error: {0}")]
WrapperGeneration(String),
#[error("Template error: {0}")]
Template(String),
#[error("WASI configuration error: {0}")]
WasiConfig(String),
#[error("Compilation error: {0}")]
Compilation(String),
#[error("File system error: {0}")]
FileSystem(String),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("MessagePack error: {0}")]
MessagePack(#[from] rmp_serde::encode::Error),
#[error("MessagePack decode error: {0}")]
MessagePackDecode(#[from] rmp_serde::decode::Error),
#[error("Invalid configuration: {0}")]
InvalidConfig(String),
#[error("Invalid path: {0:?}")]
InvalidPath(PathBuf),
#[error("Unsupported operation: {0}")]
UnsupportedOperation(String),
#[error("Security violation: {0}")]
SecurityViolation(String),
#[error("Instance not found: {0}")]
InstanceNotFound(String),
#[error("Module not found: {0}")]
ModuleNotFound(String),
#[error("Operation timed out after {0} ms")]
Timeout(u64),
#[error("{0}")]
Generic(String),
#[error(transparent)]
Other(#[from] anyhow::Error),
}
pub type Result<T> = std::result::Result<T, Error>;