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 throughinto_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 anInvokeError, 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 isFaultInfo::emptyandas_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>
impl<X> RawCallError<X>
Sourcepub fn is_rejected_before_call(&self) -> bool
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>
impl<X: Debug> Debug for RawCallError<X>
Source§impl<X: Debug> Display for RawCallError<X>
Available on non-RISC-V RV32 only.
impl<X: Debug> Display for RawCallError<X>
Source§impl<X: MatchExn> MatchExn for RawCallError<X>
impl<X: MatchExn> MatchExn for RawCallError<X>
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