pub trait PaymentError {
// Required method
fn to_problem_details(
&self,
challenge_id: Option<&str>,
) -> PaymentErrorDetails;
}Expand description
Trait for errors that can be converted to RFC 9457 Problem Details.
Implement this trait to enable automatic conversion of payment errors to standardized HTTP error responses.
§Example
use mpp::error::{PaymentError, PaymentErrorDetails};
struct MyError {
reason: String,
}
impl PaymentError for MyError {
fn to_problem_details(&self, challenge_id: Option<&str>) -> PaymentErrorDetails {
PaymentErrorDetails::core("my-error")
.with_title("MyError")
.with_status(402)
.with_detail(&self.reason)
}
}Required Methods§
Sourcefn to_problem_details(&self, challenge_id: Option<&str>) -> PaymentErrorDetails
fn to_problem_details(&self, challenge_id: Option<&str>) -> PaymentErrorDetails
Convert this error to RFC 9457 Problem Details format.
§Arguments
challenge_id- Optional challenge ID to include in the response