Skip to main content

ErrorReason

Enum ErrorReason 

Source
#[non_exhaustive]
pub enum ErrorReason {
Show 25 variants InsufficientFunds, InvalidExactEvmPayloadAuthorizationValidAfter, InvalidExactEvmPayloadAuthorizationValidBefore, InvalidExactEvmPayloadAuthorizationValueMismatch, InvalidExactEvmPayloadSignature, InvalidExactEvmPayloadRecipientMismatch, InvalidNetwork, InvalidPayload, InvalidPaymentRequirements, InvalidScheme, UnsupportedScheme, InvalidX402Version, InvalidTransactionState, UnexpectedVerifyError, UnexpectedSettleError, DuplicateSettlement, NonceAlreadyUsed, Permit2AllowanceRequired, InvalidUptoEvmPayloadSettlementExceedsAmount, UptoFacilitatorMismatch, UptoUnauthorizedFacilitator, UptoAmountExceedsPermitted, InvalidExactSolanaPayloadMemoMismatch, InvalidExactSolanaPayloadMemoCount, Custom(CompactString),
}
Expand description

Canonical error code returned on the wire when a payment fails.

The variants form a closed set of well-known codes the SDK can pattern match against. Any unknown wire code is preserved via Self::Custom so deserialisation is total and idempotent.

The enum is #[non_exhaustive]: new well-known variants may be added in minor releases without breaking semver.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

InsufficientFunds

Client does not have enough tokens to complete the payment. Wire code: insufficient_funds.

§

InvalidExactEvmPayloadAuthorizationValidAfter

Payment authorization is not yet valid (before validAfter timestamp). Wire code: invalid_exact_evm_payload_authorization_valid_after.

§

InvalidExactEvmPayloadAuthorizationValidBefore

Payment authorization has expired (after validBefore timestamp). Wire code: invalid_exact_evm_payload_authorization_valid_before.

§

InvalidExactEvmPayloadAuthorizationValueMismatch

Payment amount does not exactly match the required amount. Wire code: invalid_exact_evm_payload_authorization_value_mismatch.

§

InvalidExactEvmPayloadSignature

Payment authorization signature is invalid or improperly signed. Wire code: invalid_exact_evm_payload_signature.

§

InvalidExactEvmPayloadRecipientMismatch

Recipient address does not match payment requirements. Wire code: invalid_exact_evm_payload_recipient_mismatch.

§

InvalidNetwork

Specified blockchain network is not supported. Wire code: invalid_network.

§

InvalidPayload

Payment payload is malformed or contains invalid data. Wire code: invalid_payload.

§

InvalidPaymentRequirements

Payment requirements object is invalid or malformed. Wire code: invalid_payment_requirements.

§

InvalidScheme

Specified payment scheme is not supported. Wire code: invalid_scheme.

§

UnsupportedScheme

Payment scheme is not supported by the facilitator. Wire code: unsupported_scheme.

§

InvalidX402Version

Protocol version is not supported. Wire code: invalid_x402_version.

§

InvalidTransactionState

Blockchain transaction failed or was rejected. Wire code: invalid_transaction_state.

§

UnexpectedVerifyError

Unexpected error occurred during payment verification. Wire code: unexpected_verify_error.

§

UnexpectedSettleError

Unexpected error occurred during payment settlement. Wire code: unexpected_settle_error.

§

DuplicateSettlement

Facilitator detected a duplicate settlement attempt and rejected it. Wire code: duplicate_settlement.

§

NonceAlreadyUsed

EIP-3009 authorization nonce has already been consumed on-chain. Wire code: nonce_already_used.

§

Permit2AllowanceRequired

Permit2 allowance is insufficient; the payer must call approve on the token contract pointing at the Permit2 address first. Wire code: permit2_allowance_required. HTTP mapping: 412 Precondition Failed.

§

InvalidUptoEvmPayloadSettlementExceedsAmount

Resource server requested a settlement amount exceeding the buyer’s signed maximum authorisation. Reserved by schemes/upto/scheme_upto_evm.md §4. Wire code: invalid_upto_evm_payload_settlement_exceeds_amount.

§

UptoFacilitatorMismatch

witness.facilitator doesn’t match any of the facilitator’s signer addresses. Buyer signed a stale or unauthorised facilitator address. Wire code: upto_facilitator_mismatch.

§

UptoUnauthorizedFacilitator

On-chain proxy reverted with UnauthorizedFacilitator (msg.sender is not the witness-bound facilitator). Wire code: upto_unauthorized_facilitator.

§

UptoAmountExceedsPermitted

On-chain proxy reverted with AmountExceedsPermitted. Wire code: upto_amount_exceeds_permitted.

§

InvalidExactSolanaPayloadMemoMismatch

SVM extra.memo field did not match the memo instruction data. Wire code: invalid_exact_solana_payload_memo_mismatch.

§

InvalidExactSolanaPayloadMemoCount

Number of memo instructions attached is invalid (spec requires exactly one when extra.memo is declared). Wire code: invalid_exact_solana_payload_memo_count.

§

Custom(CompactString)

Catch-all preserving any unknown wire code verbatim. Round-trips losslessly through serialisation so clients never lose information.

Implementations§

Source§

impl ErrorReason

Source

pub fn as_str(&self) -> &str

Returns the wire-format code (snake_case per spec §9).

Source

pub fn from_wire(code: &str) -> Self

Constructs an ErrorReason from any wire code, mapping known strings to their canonical variants and preserving unknown codes as Self::Custom.

Trait Implementations§

Source§

impl Clone for ErrorReason

Source§

fn clone(&self) -> ErrorReason

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ErrorReason

Source§

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

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

impl<'de> Deserialize<'de> for ErrorReason

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ErrorReason

Source§

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

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

impl Eq for ErrorReason

Source§

impl From<&str> for ErrorReason

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<CompactString> for ErrorReason

Source§

fn from(value: CompactString) -> Self

Converts to this type from the input type.
Source§

impl From<String> for ErrorReason

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl Hash for ErrorReason

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ErrorReason

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for ErrorReason

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ErrorReason

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more