Skip to main content

wasmtime_provider/
errors.rs

1//! The crate's error module
2
3/// A convenience wrapper of `Result` that relies on
4/// [`wasmtime_provider::errors::Error`](crate::errors::Error)
5/// to hold errors
6pub(crate) type Result<T> = std::result::Result<T, Error>;
7
8/// This crate's Error type
9#[derive(thiserror::Error, Debug)]
10pub enum Error {
11  /// Wasmtime initialization failed
12  #[error("Initialization failed: {0}")]
13  InitializationFailed(String),
14
15  /// Wasmtime initialization failed
16  #[error("Initialization failed: {0} init interrupted, execution deadline exceeded")]
17  InitializationFailedTimeout(String),
18
19  /// The guest call function was not exported by the guest.
20  #[error("Guest call function (__guest_call) not exported by wasm module.")]
21  GuestCallNotFound,
22
23  /// Error originating when wasi feature is disabled, but the user provides wasi related params
24  #[error("WASI related parameter provided, but wasi feature is disabled")]
25  WasiDisabled,
26
27  /// Error originating when wasi context initialization fails
28  #[error("WASI context initialization failed: {0}")]
29  WasiInitCtxError(String),
30
31  /// Error caused when a host function cannot be registered into a wasmtime::Linker
32  #[error("Linker cannot register function '{func}': {err}")]
33  LinkerFuncDef {
34    /// wasm function that was being defined
35    func: String,
36    /// error reported
37    err: String,
38  },
39
40  /// Error caused by an invalid configuration of the [`crate::WasmtimeEngineProviderBuilder`]
41  #[error("Invalid WasmtimeEngineProviderBuilder configuration: {0}")]
42  BuilderInvalidConfig(String),
43
44  /// Error raised by wasmtime
45  #[error(transparent)]
46  Wasmtime(#[from] wasmtime::Error),
47
48  /// Generic error
49  #[error(transparent)]
50  Generic(#[from] anyhow::Error),
51}
52
53impl From<Error> for wapc::errors::Error {
54  fn from(e: Error) -> Self {
55    wapc::errors::Error::ProviderFailure(Box::new(e))
56  }
57}