Path: blob/main/crates/wasi-common/src/error.rs
1692 views
//! wasi-common uses an [`Error`] type which represents either a preview 1 [`Errno`] enum, on1//! [`anyhow::Error`] for trapping execution.2//!3//! The user can construct an [`Error`] out of an [`Errno`] using the `From`/`Into` traits.4//! They may also use [`Error::trap`] to construct an error that traps execution. The contents5//! can be inspected with [`Error::downcast`] and [`Error::downcast_ref`]. Additional context6//! can be provided with the [`Error::context`] method. This context is only observable with the7//! `Display` and `Debug` impls of the error.89pub use crate::snapshots::preview_1::error::{Error, ErrorExt};10use std::fmt;1112/// An error returned from the `proc_exit` host syscall.13///14/// Embedders can test if an error returned from wasm is this error, in which15/// case it may signal a non-fatal trap.16#[derive(Debug)]17pub struct I32Exit(pub i32);1819impl fmt::Display for I32Exit {20fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {21write!(f, "Exited with i32 exit status {}", self.0)22}23}2425impl std::error::Error for I32Exit {}262728