pub struct RawException { /* private fields */ }Expand description
An exception caught and detached from the call scratch: the payload is
copied once, into storage owned by the value itself, so it survives
arbitrary later SDK operations (including re-use of the call scratch).
Without alloc that storage is a fixed SCRATCH_MAX-capacity inline
buffer, so the value (and any error enum holding it) is roughly 4 KiB;
under alloc it is an exact-size heap allocation.
Use MapExceptions when a compact classification
is enough and the original wire bytes do not need to outlive the call.
Deliberately not encodable: there is no WriteXDR impl.
re_throw aborts with the verbatim wire bytes;
try_as decodes to a typed exception, with
selector / payload for raw
inspection.
Implementations§
Source§impl RawException
impl RawException
pub fn selector(&self) -> u64
pub fn try_as<T: Exn + ReadXDROwned>(&self) -> Option<T>
Sourcepub fn try_decode<T: Exn + ReadXDROwned>(&self) -> Option<Result<T, ReadError>>
pub fn try_decode<T: Exn + ReadXDROwned>(&self) -> Option<Result<T, ReadError>>
Sourcepub fn new(selector: u64, payload: &[u8]) -> Self
pub fn new(selector: u64, payload: &[u8]) -> Self
Build from a selector and payload. Test/mock construction.
Sourcepub fn from_abort_buf(bytes: &[u8]) -> Result<Self, LibraryExn>
pub fn from_abort_buf(bytes: &[u8]) -> Result<Self, LibraryExn>
Parse an abort wire buffer ([CXS(selector)][payload]) into an owned
exception. Host tests and mock plumbing.
Trait Implementations§
Source§impl Debug for RawException
impl Debug for RawException
Source§impl From<RawExceptionRef<'_>> for RawException
What RawExceptionRef::to_owned produces: one copy. Any number may
be live at once; without alloc each value carries its own fixed
SCRATCH_MAX-capacity buffer.
impl From<RawExceptionRef<'_>> for RawException
What RawExceptionRef::to_owned produces: one copy. Any number may
be live at once; without alloc each value carries its own fixed
SCRATCH_MAX-capacity buffer.
Source§fn from(exn: RawExceptionRef<'_>) -> Self
fn from(exn: RawExceptionRef<'_>) -> Self
Source§impl MatchExn for RawException
impl MatchExn for RawException
Source§fn as_exn(&self) -> Option<RawExceptionRef<'_>>
fn as_exn(&self) -> Option<RawExceptionRef<'_>>
None if this failure carries none (a
fault, an invalid call, an encode/decode failure).Source§fn try_as<E: Exn + ReadXDROwned>(&self) -> Option<E>
fn try_as<E: Exn + ReadXDROwned>(&self) -> Option<E>
E if this failure carries an exception of that type. Read more