pub struct UserError { /* private fields */ }Expand description
The error that is sent back to users of IC if something goes wrong. It’s designed to be copyable and serializable so that we can persist it in ingress history.
Implementations§
Source§impl UserError
impl UserError
pub fn new<S: ToString>(code: ErrorCode, description: S) -> Self
Sourcepub fn from_proto<S: ToString>(code: ErrorCode, description: S) -> Self
pub fn from_proto<S: ToString>(code: ErrorCode, description: S) -> Self
Constructs a UserError retaining the original description without truncation.
This ensures backward compatibility with ingress history.
§Safety
This constructor is specifically intended for state-loading. Avoid usage in other contexts.
pub fn code(&self) -> ErrorCode
pub fn description(&self) -> &str
pub fn reject_code(&self) -> RejectCode
pub fn is_system_error(&self) -> bool
pub fn count_bytes(&self) -> usize
Sourcepub fn assert_contains(&self, code: ErrorCode, description: &str)
pub fn assert_contains(&self, code: ErrorCode, description: &str)
Panics if the error doesn’t have the expected code and description. Useful for tests to avoid matching exact error messages.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for UserError
impl<'de> Deserialize<'de> for UserError
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 Error for UserError
impl Error for UserError
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 Ord for UserError
impl Ord for UserError
Source§impl PartialOrd for UserError
impl PartialOrd for UserError
impl Eq for UserError
impl StructuralPartialEq for UserError
Auto Trait Implementations§
impl Freeze for UserError
impl RefUnwindSafe for UserError
impl Send for UserError
impl Sync for UserError
impl Unpin for UserError
impl UnwindSafe for UserError
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