pub enum ApiError {
Unknown(ActionAddress),
MissingArgument(ActionAddress),
UnexpectedArgument(ActionAddress),
InvalidArguments(String),
ArgumentOutOfRange {
param: String,
violation: ArgViolation,
},
Unavailable {
code: String,
reason: String,
},
ConfirmationRequired,
UnregisteredType(String),
Refused {
code: String,
reason: String,
},
Failed(String),
}Expand description
Why an address could not be performed. Unknown is “nothing publishes this address”; an action
published there that the caller’s permissions keep from them is refused as permission_denied
(ApiError::Unavailable), saying why.
Variants§
Unknown(ActionAddress)
Nothing in the tree carries this address.
MissingArgument(ActionAddress)
The action takes text and none was supplied.
UnexpectedArgument(ActionAddress)
The action takes nothing and an argument was supplied. Refused, not dropped — a silently ignored argument leaves the caller believing it asked for something it didn’t get.
InvalidArguments(String)
Typed arguments failed the action’s declared schema.
ArgumentOutOfRange
A typed argument is a number outside the range its parameter
declares: InvalidArguments whose bound
reaches the caller as data (ApiError::failure_details).
The address exists and is intentionally advertised, but its current precondition is not satisfied.
ConfirmationRequired
The action contract requires an explicit confirmation step that this invocation did not carry.
UnregisteredType(String)
The app never registered a decoder for the action’s type, so the API can’t prove what it would run. Fail-closed: a refusal, not a best-effort apply.
Refused
The app declined for a reason it named by a stable code (the thing it would add is there already, say), in words beside it for whoever reads: a caller decides on the code without reading the words.
Failed(String)
The action ran and failed.
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn decoding(error: ActionError) -> Self
pub fn decoding(error: ActionError) -> Self
Why an encoded action could not be turned back into one: no decoder for its type, or a payload the registered decoder does not read (the code that encoded it and the code decoding it disagree). The second is a fault of its own and says so; reporting it as an unknown type sends whoever reads it looking for a registration that is there.
Sourcepub fn refused(error: ActionError) -> Self
pub fn refused(error: ActionError) -> Self
error as the caller reads it: an app that named why keeps its code
as data, so a caller decides on it without reading the words.
Sourcepub fn code(&self) -> &str
pub fn code(&self) -> &str
Stable machine-readable code, distinguishing “I addressed this wrongly” from “it ran and could not do its job”.
Sourcepub fn failure_details(&self) -> Option<Value>
pub fn failure_details(&self) -> Option<Value>
What an ActionFailure reporting this
refusal carries beside its message, for a caller to act on without
reading prose: {"param": …, "violation": …} for an argument out of
its declared range, {"code": …, "reason": …} for an action that is unavailable, so a
caller tells why (the person’s own view, a policy) by its code.
Trait Implementations§
impl Eq for ApiError
Source§impl Error for ApiError
impl Error for ApiError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<ArgError> for ApiError
An argument out of its declared range keeps its bound as data; every
other argument refusal is reported in words.
impl From<ArgError> for ApiError
An argument out of its declared range keeps its bound as data; every other argument refusal is reported in words.
impl StructuralPartialEq for ApiError
Auto Trait Implementations§
impl Forget for ApiError
impl Freeze for ApiError
impl Move for ApiError
impl RefUnwindSafe for ApiError
impl Send for ApiError
impl Sync for ApiError
impl Unpin for ApiError
impl UnsafeUnpin for ApiError
impl UnwindSafe for ApiError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§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> ⓘ
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> ⓘ
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 more