Skip to main content

wasmtime_internal_core/error/
mod.rs

1//! Wasmtime's universal error handling types.
2//!
3//! 99% API-compatible with `anyhow`, but additionally handles out-of-memory
4//! errors, instead of aborting the process.
5//!
6//! See the [`Error`] documentation for more details.
7
8#[cfg(feature = "backtrace")]
9mod backtrace;
10mod boxed;
11mod context;
12mod error;
13mod oom;
14mod ptr;
15#[cfg(feature = "anyhow")]
16mod to_wasmtime_result;
17mod vtable;
18
19#[doc(hidden)]
20pub mod macros;
21
22pub use crate::{bail, ensure, format_err};
23#[cfg(feature = "backtrace")]
24pub use backtrace::disable_backtrace;
25pub use context::Context;
26pub use error::*;
27pub use oom::OutOfMemory;
28#[cfg(feature = "anyhow")]
29pub use to_wasmtime_result::ToWasmtimeResult;
30
31/// A result of either `Ok(T)` or an [`Err(Error)`][Error].
32pub type Result<T, E = Error> = core::result::Result<T, E>;
33
34/// Return `core::result::Result::<T, wasmtime::Error>::Ok(value)`.
35///
36/// Useful in situations where Rust's type inference cannot figure out that the
37/// `Result`'s error type is [`Error`].
38#[allow(non_snake_case, reason = "matching anyhow API")]
39pub fn Ok<T>(value: T) -> Result<T> {
40    core::result::Result::Ok(value)
41}