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;
15mod to_wasmtime_result;
16mod vtable;
17
18#[doc(hidden)]
19pub mod macros;
20
21pub use crate::{bail, ensure, format_err};
22#[cfg(feature = "backtrace")]
23pub use backtrace::disable_backtrace;
24pub use context::Context;
25pub use error::*;
26pub use oom::OutOfMemory;
27pub use to_wasmtime_result::ToWasmtimeResult;
28
29/// A result of either `Ok(T)` or an [`Err(Error)`][Error].
30pub type Result<T, E = Error> = core::result::Result<T, E>;
31
32/// Return `core::result::Result::<T, wasmtime::Error>::Ok(value)`.
33///
34/// Useful in situations where Rust's type inference cannot figure out that the
35/// `Result`'s error type is [`Error`].
36#[allow(non_snake_case, reason = "matching anyhow API")]
37pub fn Ok<T>(value: T) -> Result<T> {
38    core::result::Result::Ok(value)
39}