refactor(errors): error enums to use 'static str (#472)

This commit is contained in:
Narayan Bhat
2023-01-30 18:57:05 +05:30
committed by GitHub
parent fa7d087c0d
commit 24351a6c85
25 changed files with 84 additions and 79 deletions

View File

@ -20,7 +20,10 @@ pub enum StripeErrorCode {
InvalidRequestUrl,
#[error(error_type = StripeErrorType::InvalidRequestError, code = "parameter_missing", message = "Missing required param: {field_name}.")]
ParameterMissing { field_name: String, param: String },
ParameterMissing {
field_name: &'static str,
param: &'static str,
},
#[error(
error_type = StripeErrorType::InvalidRequestError, code = "parameter_unknown",
@ -327,7 +330,7 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
| errors::ApiErrorResponse::InvalidHttpMethod => Self::InvalidRequestUrl,
errors::ApiErrorResponse::MissingRequiredField { field_name } => {
Self::ParameterMissing {
field_name: field_name.to_owned(),
field_name,
param: field_name,
}
}
@ -395,8 +398,8 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
Self::PreconditionFailed { message }
}
errors::ApiErrorResponse::InvalidDataValue { field_name } => Self::ParameterMissing {
field_name: field_name.to_owned(),
param: field_name.to_owned(),
field_name,
param: field_name,
},
errors::ApiErrorResponse::MaximumRefundCount => Self::MaximumRefundCount,
errors::ApiErrorResponse::PaymentNotSucceeded => Self::PaymentFailed,