Skip to main content

RawCallError

Enum RawCallError 

Source
pub enum RawCallError<X = RawException> {
    Invalid,
    Reentrance,
    DepthExceeded,
    InvokeRejected(SysErr),
    Exception(X),
    Fault(FaultInfo),
    UnparseableReturn(FaultString),
    UnparseableAbort(FaultString),
    UnparseableAuthHandles(FaultString),
    EncodingArgs(FaultString),
}
Expand description

The raw, untyped error from a contract call.

Generic over the exception representation X, which try_call_raw_with’s on_exn closure chooses: the default RawException (one copy, via to_owned), a typed error enum, or Infallible if the closure re-throws unconditionally.

The variants divide by how far the call got. Invalid, Reentrance, DepthExceeded and InvokeRejected all mean the invoke syscall was refused before any child frame ran, so the call was a complete no-op. Exception and Fault mean a child frame ran and then aborted or died. The rest are encode/decode failures in this contract, on either side of a call that otherwise completed.

Variants§

§

Invalid

The invoke syscall rejected the call as malformed: no contract at the target address, invalid invoke flags, or an auth token id that is malformed, duplicated, or not owned by this frame.

§

Reentrance

The target address already has a frame open on the invocation stack, so the runtime refused the call as reentrant.

The call can never succeed anywhere in this call chain — unlike DepthExceeded, retrying from a shallower frame does not help while this address is still on the stack.

§

DepthExceeded

The transaction already holds the network’s maximum number of open invocation frames, so admitting another would exceed the cross-invoke depth bound.

A resource limit rather than a malformed call: the same invocation succeeds when made from a shallower frame.

§

InvokeRejected(SysErr)

The invoke syscall was refused with a code this SDK does not model.

Carries the raw code rather than collapsing an unrecognized rejection into a neighbouring variant’s meaning.

§

Exception(X)

The called contract threw an exception with a selector-tagged error.

§

Fault(FaultInfo)

A child frame ran and terminated without producing a result: a panic, a trap, or exhausting its gas.

The message is host-side state recorded beside the call, never something the callee sent: the runtime reports a faulted child as a bare frame status with neither a return nor an abort buffer, so no message crosses the call boundary and none ever will. That splits the two cases:

  • A frame the native harness ran itself — the root frame of an env.transact, reaching here through into_root_call_result. The harness caught that panic, so the message is the panicking body’s own. A frame that died with no ordinary panic to catch leaves it empty: running out of gas unwinds an InvokeError, which carries no message.
  • A raw_Invokeed callee — caught inside the runtime’s own frame, where there is nothing to attribute a message against, so the payload is FaultInfo::empty and as_str() reads "<fault>". Reporting anything else here would mean reporting some other frame’s message.

See FaultInfo for what the payload holds and where.

A callee that wants its failure to be legible to its caller — on chain, not just in a host test — must abort with an exception rather than fault.

§

UnparseableReturn(FaultString)

Decode error: the called contract returned some unparseable return result

§

UnparseableAbort(FaultString)

Decode error: the called contract aborted with some unparseable result

§

UnparseableAuthHandles(FaultString)

Decode error: the called contract aborted with some unparseable result

§

EncodingArgs(FaultString)

Encode error: the arguments supplied failed to encode

Implementations§

Source§

impl<X> RawCallError<X>

Source

pub fn is_rejected_before_call(&self) -> bool

Whether the invoke syscall was refused before any child frame ran.

True for Invalid, Reentrance, DepthExceeded and InvokeRejected. When this holds the call was a complete no-op: the callee did not run, observed nothing, and wrote nothing.

Trait Implementations§

Source§

impl<X: Debug> Debug for RawCallError<X>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<X: Debug> Display for RawCallError<X>

Available on non-RISC-V RV32 only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<X: MatchExn> MatchExn for RawCallError<X>

Source§

fn as_exn(&self) -> Option<RawExceptionRef<'_>>

The caught exception, or 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>

Decode as E if this failure carries an exception of that type. Read more
Source§

fn try_decode<E: Exn + ReadXDROwned>(&self) -> Option<Result<E, ReadError>>

try_as with the decode failure kept separate: Read more
Source§

impl<X: PartialEq> PartialEq for RawCallError<X>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<X: ReThrow> ReThrow for RawCallError<X>

Source§

fn re_throw(self) -> !

Re-throw this error. Exceptions are propagated as exceptions; faults panic (a fault stays a fault).
Source§

impl<X: PartialEq> StructuralPartialEq for RawCallError<X>

Auto Trait Implementations§

§

impl<X> Freeze for RawCallError<X>
where X: Freeze,

§

impl<X> RefUnwindSafe for RawCallError<X>
where X: RefUnwindSafe,

§

impl<X> Send for RawCallError<X>
where X: Send,

§

impl<X> Sync for RawCallError<X>
where X: Sync,

§

impl<X> Unpin for RawCallError<X>
where X: Unpin,

§

impl<X> UnsafeUnpin for RawCallError<X>
where X: UnsafeUnpin,

§

impl<X> UnwindSafe for RawCallError<X>
where X: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Context for T
where T: Any + Display,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> StaticIfNoAlloc for T

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.