pub enum WasmError {
ManifestError(String),
WasmError {
context: &'static str,
message: String,
},
GetFuncTypedError {
context: &'static str,
func_name: String,
expected_params: String,
expected_result: String,
err: Error,
},
}Expand description
§WebAssembly Error Types
WasmError represents the various errors that can occur during WebAssembly operations
in the Theater system. These errors provide context about what operation failed and why.
§Purpose
This enum centralizes error handling for WebAssembly-related operations, providing detailed context to help diagnose issues during component loading, instantiation, and function calls. Each variant includes context about where the error occurred.
§Example
ⓘ
use theater::WasmError;
use anyhow::Result;
fn handle_wasm_operation() -> Result<(), WasmError> {
// Simulate a function call that might fail
let call_failed = true; // Example condition
if call_failed {
return Err(WasmError::WasmError {
context: "function_call",
message: "Failed to call 'greet' function".to_string(),
});
}
Ok(())
}§Implementation Notes
These errors are typically converted to anyhow::Error before being propagated
to the caller, but the contextual information is preserved.
Variants§
Trait Implementations§
Source§impl Error for WasmError
impl Error for WasmError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for WasmError
impl RefUnwindSafe for WasmError
impl Send for WasmError
impl Sync for WasmError
impl Unpin for WasmError
impl UnwindSafe for WasmError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more