Fixing isssues usins AI

This commit is contained in:
Muluhabt
2026-07-22 17:29:40 +03:00
parent 9782dd0fe3
commit e31a2d64e5
2 changed files with 20 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
import {
BadGatewayException,
BadRequestException,
ConflictException,
Injectable,
Logger,
} from "@nestjs/common";
@@ -154,11 +155,16 @@ export class PaymentClientService {
} catch (err) {
if (err instanceof AxiosError && err.response) {
// 4xx/5xx from the payment service: propagate 404 to callers that handle it;
// everything else is a gateway-level failure from the client's perspective.
// 409 = a legitimate conflict (e.g. another provider's payment is already in
// flight for this booking) — surface its message as-is rather than masking it as
// a gateway failure; everything else is a genuine gateway-level failure.
if (err.response.status === 404) throw err;
const detail =
(err.response.data as { message?: string | string[] })?.message ??
err.message;
if (err.response.status === 409) {
throw new ConflictException(detail);
}
this.logger.error(
`payment service ${method} ${path}${err.response.status}: ${detail}`,
);