Skip to main content

MppError

Enum MppError 

Source
pub enum MppError {
Show 26 variants AmountExceedsMax { required: u128, max: u128, }, InvalidAmount(String), InvalidConfig(String), Http(String), ChainIdMismatch { expected: u64, got: u64, }, Json(Error), UnsupportedPaymentMethod(String), MissingHeader(String), InvalidBase64Url(String), MalformedCredential(Option<String>), InvalidChallenge { id: Option<String>, reason: Option<String>, }, VerificationFailed(Option<String>), PaymentExpired(Option<String>), PaymentRequired { realm: Option<String>, description: Option<String>, }, InvalidPayload(Option<String>), BadRequest(Option<String>), InsufficientBalance(Option<String>), InvalidSignature(Option<String>), SignerMismatch(Option<String>), AmountExceedsDeposit(Option<String>), DeltaTooSmall(Option<String>), ChannelNotFound(Option<String>), ChannelClosed(Option<String>), Io(Error), InvalidUtf8(FromUtf8Error), SystemTime(SystemTimeError),
}

Variants§

§

AmountExceedsMax

Required amount exceeds user’s maximum allowed

Fields

§required: u128
§max: u128
§

InvalidAmount(String)

Invalid amount format

§

InvalidConfig(String)

Configuration is invalid

§

Http(String)

HTTP request/response error

§

ChainIdMismatch

Chain ID mismatch between challenge and provider

Fields

§expected: u64
§got: u64
§

Json(Error)

JSON serialization/deserialization error

§

UnsupportedPaymentMethod(String)

Unsupported payment method

§

MissingHeader(String)

Missing required header

§

InvalidBase64Url(String)

Invalid base64url encoding

§

MalformedCredential(Option<String>)

Credential is malformed (invalid base64url, bad JSON structure).

§

InvalidChallenge

Challenge ID is unknown, expired, or already used.

Fields

§reason: Option<String>
§

VerificationFailed(Option<String>)

Payment proof is invalid or verification failed.

§

PaymentExpired(Option<String>)

Payment has expired.

§

PaymentRequired

No credential was provided but payment is required.

Fields

§description: Option<String>
§

InvalidPayload(Option<String>)

Credential payload does not match the expected schema.

§

BadRequest(Option<String>)

Request is malformed or contains invalid parameters.

§

InsufficientBalance(Option<String>)

Insufficient balance in payment channel.

§

InvalidSignature(Option<String>)

Invalid cryptographic signature.

§

SignerMismatch(Option<String>)

Signer does not match expected address.

§

AmountExceedsDeposit(Option<String>)

Voucher amount exceeds channel deposit.

§

DeltaTooSmall(Option<String>)

Voucher delta is below the minimum threshold.

§

ChannelNotFound(Option<String>)

Payment channel not found.

§

ChannelClosed(Option<String>)

Payment channel has been closed.

§

Io(Error)

IO error

§

InvalidUtf8(FromUtf8Error)

Invalid UTF-8 in response

§

SystemTime(SystemTimeError)

System time error

Implementations§

Source§

impl MppError

Source

pub fn unsupported_method(method: &impl Display) -> Self

Create an unsupported payment method error

Source

pub fn malformed_credential(reason: impl Into<String>) -> Self

Create a malformed credential error.

Source

pub fn malformed_credential_default() -> Self

Create a malformed credential error without a reason.

Source

pub fn invalid_challenge_id(id: impl Into<String>) -> Self

Create an invalid challenge error with ID.

Source

pub fn invalid_challenge_reason(reason: impl Into<String>) -> Self

Create an invalid challenge error with reason.

Source

pub fn invalid_challenge( id: impl Into<String>, reason: impl Into<String>, ) -> Self

Create an invalid challenge error with ID and reason.

Source

pub fn invalid_challenge_default() -> Self

Create an invalid challenge error without details.

Source

pub fn verification_failed(reason: impl Into<String>) -> Self

Create a verification failed error.

Source

pub fn verification_failed_default() -> Self

Create a verification failed error without a reason.

Source

pub fn payment_expired(expires: impl Into<String>) -> Self

Create a payment expired error with expiration timestamp.

Source

pub fn payment_expired_default() -> Self

Create a payment expired error without timestamp.

Source

pub fn payment_required_realm(realm: impl Into<String>) -> Self

Create a payment required error with realm.

Source

pub fn payment_required_description(description: impl Into<String>) -> Self

Create a payment required error with description.

Source

pub fn payment_required( realm: impl Into<String>, description: impl Into<String>, ) -> Self

Create a payment required error with realm and description.

Source

pub fn payment_required_default() -> Self

Create a payment required error without details.

Source

pub fn invalid_payload(reason: impl Into<String>) -> Self

Create an invalid payload error.

Source

pub fn invalid_payload_default() -> Self

Create an invalid payload error without a reason.

Source

pub fn bad_request(reason: impl Into<String>) -> Self

Create a bad request error.

Source

pub fn bad_request_default() -> Self

Create a bad request error without a reason.

Source

pub fn problem_type_suffix(&self) -> Option<&'static str>

Returns the RFC 9457 problem type suffix if this is a payment problem.

Source

pub fn is_payment_problem(&self) -> bool

Returns true if this error is an RFC 9457 payment problem.

Trait Implementations§

Source§

impl Debug for MppError

Source§

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

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

impl Display for MppError

Source§

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

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

impl Error for MppError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for MppError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for MppError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<FromUtf8Error> for MppError

Source§

fn from(source: FromUtf8Error) -> Self

Converts to this type from the input type.
Source§

impl From<SystemTimeError> for MppError

Source§

fn from(source: SystemTimeError) -> Self

Converts to this type from the input type.
Source§

impl PaymentError for MppError

Source§

fn to_problem_details(&self, challenge_id: Option<&str>) -> PaymentErrorDetails

Convert this error to RFC 9457 Problem Details format. Read more

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