mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 12:06:56 +08:00
chore(router): added generic unauthorized response (#450)
This commit is contained in:
@ -321,6 +321,7 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
|
||||
match value {
|
||||
errors::ApiErrorResponse::Unauthorized
|
||||
| errors::ApiErrorResponse::InvalidJwtToken
|
||||
| errors::ApiErrorResponse::GenericUnauthorized { .. }
|
||||
| errors::ApiErrorResponse::InvalidEphermeralKey => Self::Unauthorized,
|
||||
errors::ApiErrorResponse::InvalidRequestUrl
|
||||
| errors::ApiErrorResponse::InvalidHttpMethod => Self::InvalidRequestUrl,
|
||||
|
||||
@ -73,6 +73,11 @@ pub enum ApiErrorResponse {
|
||||
message = "Access forbidden, invalid JWT token was used."
|
||||
)]
|
||||
InvalidJwtToken,
|
||||
#[error(
|
||||
error_type = ErrorType::InvalidRequestError, code = "IR_12",
|
||||
message = "{message}",
|
||||
)]
|
||||
GenericUnauthorized { message: String },
|
||||
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_01", message = "Payment failed while processing with connector. Retry payment.")]
|
||||
PaymentAuthorizationFailed { data: Option<serde_json::Value> },
|
||||
@ -179,9 +184,10 @@ impl actix_web::ResponseError for ApiErrorResponse {
|
||||
use reqwest::StatusCode;
|
||||
|
||||
match self {
|
||||
Self::Unauthorized | Self::InvalidEphermeralKey | Self::InvalidJwtToken => {
|
||||
StatusCode::UNAUTHORIZED
|
||||
} // 401
|
||||
Self::Unauthorized
|
||||
| Self::InvalidEphermeralKey
|
||||
| Self::InvalidJwtToken
|
||||
| Self::GenericUnauthorized { .. } => StatusCode::UNAUTHORIZED, // 401
|
||||
Self::ExternalConnectorError { status_code, .. } => {
|
||||
StatusCode::from_u16(*status_code).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user