pub struct WasmError {
pub code: ErrorCode,
pub message: String,
pub details: Option<String>,
pub recoverable: bool,
}Expand description
A structured WASM error.
Fields§
§code: ErrorCodeError category.
message: StringHuman-readable message.
details: Option<String>Optional additional detail (stack trace, inner error, etc.).
recoverable: booltrue if the caller may retry or recover; false for fatal errors.
Implementations§
Source§impl WasmError
impl WasmError
Sourcepub fn new(code: ErrorCode, message: impl Into<String>) -> Self
pub fn new(code: ErrorCode, message: impl Into<String>) -> Self
Create a new, recoverable error.
Sourcepub fn with_details(self, details: impl Into<String>) -> Self
pub fn with_details(self, details: impl Into<String>) -> Self
Attach additional detail text (builder pattern).
Sourcepub fn unrecoverable(self) -> Self
pub fn unrecoverable(self) -> Self
Mark the error as unrecoverable (builder pattern).
Sourcepub fn from_code(code: u32, message: &str) -> Option<Self>
pub fn from_code(code: u32, message: &str) -> Option<Self>
Convenience constructor: attempt to build from a numeric code.
Returns None when code does not map to a known ErrorCode.
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Returns true for “client-side” errors: codes 1, 4, 7, 8.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Returns true for “server/transport” errors: codes 2, 5, 6.
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 UnsafeUnpin 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