mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 05:17:02 +08:00
feat(errors): add GenericDuplicateError inApiErrorResponse (#1792)
This commit is contained in:
committed by
GitHub
parent
04c3de73a5
commit
7f947169fe
@ -91,6 +91,9 @@ pub enum StripeErrorCode {
|
|||||||
#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "{message}")]
|
#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "{message}")]
|
||||||
GenericNotFoundError { message: String },
|
GenericNotFoundError { message: String },
|
||||||
|
|
||||||
|
#[error(error_type = StripeErrorType::InvalidRequestError, code = "duplicate_resource", message = "{message}")]
|
||||||
|
GenericDuplicateError { message: String },
|
||||||
|
|
||||||
#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such merchant account")]
|
#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such merchant account")]
|
||||||
MerchantAccountNotFound,
|
MerchantAccountNotFound,
|
||||||
|
|
||||||
@ -411,6 +414,9 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
|
|||||||
errors::ApiErrorResponse::GenericNotFoundError { message } => {
|
errors::ApiErrorResponse::GenericNotFoundError { message } => {
|
||||||
Self::GenericNotFoundError { message }
|
Self::GenericNotFoundError { message }
|
||||||
}
|
}
|
||||||
|
errors::ApiErrorResponse::GenericDuplicateError { message } => {
|
||||||
|
Self::GenericDuplicateError { message }
|
||||||
|
}
|
||||||
// parameter unknown, invalid request error // actually if we type wrong values in address we get this error. Stripe throws parameter unknown. I don't know if stripe is validating email and stuff
|
// parameter unknown, invalid request error // actually if we type wrong values in address we get this error. Stripe throws parameter unknown. I don't know if stripe is validating email and stuff
|
||||||
errors::ApiErrorResponse::InvalidDataFormat {
|
errors::ApiErrorResponse::InvalidDataFormat {
|
||||||
field_name,
|
field_name,
|
||||||
@ -607,6 +613,7 @@ impl actix_web::ResponseError for StripeErrorCode {
|
|||||||
| Self::PaymentIntentMandateInvalid { .. }
|
| Self::PaymentIntentMandateInvalid { .. }
|
||||||
| Self::PaymentIntentUnexpectedState { .. }
|
| Self::PaymentIntentUnexpectedState { .. }
|
||||||
| Self::DuplicatePayment { .. }
|
| Self::DuplicatePayment { .. }
|
||||||
|
| Self::GenericDuplicateError { .. }
|
||||||
| Self::IncorrectConnectorNameGiven
|
| Self::IncorrectConnectorNameGiven
|
||||||
| Self::ResourceMissing { .. }
|
| Self::ResourceMissing { .. }
|
||||||
| Self::FileValidationFailed
|
| Self::FileValidationFailed
|
||||||
|
|||||||
@ -207,6 +207,8 @@ pub enum ApiErrorResponse {
|
|||||||
MissingFileContentType,
|
MissingFileContentType,
|
||||||
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_05", message = "{message}")]
|
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_05", message = "{message}")]
|
||||||
GenericNotFoundError { message: String },
|
GenericNotFoundError { message: String },
|
||||||
|
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_01", message = "{message}")]
|
||||||
|
GenericDuplicateError { message: String },
|
||||||
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_01", message = "Failed to authenticate the webhook")]
|
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_01", message = "Failed to authenticate the webhook")]
|
||||||
WebhookAuthenticationFailed,
|
WebhookAuthenticationFailed,
|
||||||
#[error(error_type = ErrorType::ObjectNotFound, code = "WE_04", message = "Webhook resource not found")]
|
#[error(error_type = ErrorType::ObjectNotFound, code = "WE_04", message = "Webhook resource not found")]
|
||||||
|
|||||||
@ -135,6 +135,9 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon
|
|||||||
Self::DuplicatePayout { payout_id } => {
|
Self::DuplicatePayout { payout_id } => {
|
||||||
AER::BadRequest(ApiError::new("HE", 1, format!("The payout with the specified payout_id '{payout_id}' already exists in our records"), None))
|
AER::BadRequest(ApiError::new("HE", 1, format!("The payout with the specified payout_id '{payout_id}' already exists in our records"), None))
|
||||||
}
|
}
|
||||||
|
Self::GenericDuplicateError { message } => {
|
||||||
|
AER::BadRequest(ApiError::new("HE", 1, message, None))
|
||||||
|
}
|
||||||
Self::RefundNotFound => {
|
Self::RefundNotFound => {
|
||||||
AER::NotFound(ApiError::new("HE", 2, "Refund does not exist in our records.", None))
|
AER::NotFound(ApiError::new("HE", 2, "Refund does not exist in our records.", None))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user