pub enum EffectError {
NotFound {
resource: String,
},
InvalidInput {
message: String,
},
NetworkError {
message: String,
},
PermissionDenied {
message: String,
},
Timeout {
message: String,
},
Custom {
code: String,
message: String,
data: Option<Value>,
},
}Expand description
Effect-specific error with common variants and Custom fallback.
This error type is returned by effect handlers when operations fail. It provides structured information that can be serialized across the WASM boundary and handled programmatically by the guest.
§Common Patterns
NotFound: Resource doesn’t exist (file, issue, entity)InvalidInput: Request parameters failed validationNetworkError: External service unreachable or returned errorCustom: Domain-specific errors with extensible structure
§Example
ⓘ
use crate::effects::EffectError;
fn find_entity(id: &str) -> Result<(), EffectError> {
// Simulate a lookup that fails
if id == "not_found" {
Err(EffectError::not_found(format!("entity/{}", id)))
} else {
Ok(())
}
}Variants§
NotFound
Resource not found.
InvalidInput
Invalid input parameters.
NetworkError
Network or external service error.
PermissionDenied
Permission denied.
Timeout
Operation timed out.
Custom
Custom domain-specific error.
Use this for errors that don’t fit the common patterns above. External consumers can define their own error codes and structures.
Implementations§
Source§impl EffectError
impl EffectError
Sourcepub fn invalid_input(message: impl Into<String>) -> Self
pub fn invalid_input(message: impl Into<String>) -> Self
Create an invalid input error.
Sourcepub fn network_error(message: impl Into<String>) -> Self
pub fn network_error(message: impl Into<String>) -> Self
Create a network error.
Sourcepub fn permission_denied(message: impl Into<String>) -> Self
pub fn permission_denied(message: impl Into<String>) -> Self
Create a permission denied error.
Trait Implementations§
Source§impl Clone for EffectError
impl Clone for EffectError
Source§fn clone(&self) -> EffectError
fn clone(&self) -> EffectError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EffectError
impl Debug for EffectError
Source§impl<'de> Deserialize<'de> for EffectError
impl<'de> Deserialize<'de> for EffectError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for EffectError
impl Display for EffectError
Source§impl Error for EffectError
impl Error for EffectError
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()
Source§impl PartialEq for EffectError
impl PartialEq for EffectError
Source§impl Serialize for EffectError
impl Serialize for EffectError
impl StructuralPartialEq for EffectError
Auto Trait Implementations§
impl Freeze for EffectError
impl RefUnwindSafe for EffectError
impl Send for EffectError
impl Sync for EffectError
impl Unpin for EffectError
impl UnwindSafe for EffectError
Blanket Implementations§
Source§impl<T> AsErrorSource for Twhere
T: Error + 'static,
impl<T> AsErrorSource for Twhere
T: Error + 'static,
Source§fn as_error_source(&self) -> &(dyn Error + 'static)
fn as_error_source(&self) -> &(dyn Error + 'static)
For maximum effectiveness, this needs to be called as a method
to benefit from Rust’s automatic dereferencing of method
receivers.
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromResponse for Twhere
T: DeserializeOwned,
impl<T> FromResponse for Twhere
T: DeserializeOwned,
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
Set the “status” flags for the
self file descriptor. Read moreSource§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.