1 //! wasi-common uses an [`Error`] type which represents either a preview 1 [`Errno`] enum, on
2 //! [`wasmtime_environ::error::Error`] for trapping execution.
3 //!
4 //! The user can construct an [`Error`] out of an [`Errno`] using the `From`/`Into` traits.
5 //! They may also use [`Error::trap`] to construct an error that traps execution. The contents
6 //! can be inspected with [`Error::downcast`] and [`Error::downcast_ref`]. Additional context
7 //! can be provided with the [`Error::context`] method. This context is only observable with the
8 //! `Display` and `Debug` impls of the error.
9 
10 pub use crate::snapshots::preview_1::error::{Error, ErrorExt};
11 use std::fmt;
12 
13 /// An error returned from the `proc_exit` host syscall.
14 ///
15 /// Embedders can test if an error returned from wasm is this error, in which
16 /// case it may signal a non-fatal trap.
17 #[derive(Debug)]
18 pub struct I32Exit(pub i32);
19 
20 impl fmt::Display for I32Exit {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result21     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22         write!(f, "Exited with i32 exit status {}", self.0)
23     }
24 }
25 
26 impl std::error::Error for I32Exit {}
27