forked from Yara724/api
Better error handling for different insurers
This commit is contained in:
@@ -158,6 +158,16 @@ export class RequestManagementService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Keep eligibility rejections distinct from an unavailable CAR_BODY provider. */
|
||||||
|
private throwCarBodyInquiryFailure(err: unknown): never {
|
||||||
|
if (err instanceof ForbiddenException) throw err;
|
||||||
|
|
||||||
|
throw new HttpException(
|
||||||
|
"Car body inquiry failed",
|
||||||
|
HttpStatus.BAD_REQUEST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private stepKeyToPartyRole(stepKey: WorkflowStep): PartyRole {
|
private stepKeyToPartyRole(stepKey: WorkflowStep): PartyRole {
|
||||||
if (String(stepKey).startsWith("FIRST_")) return PartyRole.FIRST;
|
if (String(stepKey).startsWith("FIRST_")) return PartyRole.FIRST;
|
||||||
if (String(stepKey).startsWith("SECOND_")) return PartyRole.SECOND;
|
if (String(stepKey).startsWith("SECOND_")) return PartyRole.SECOND;
|
||||||
@@ -1563,10 +1573,7 @@ export class RequestManagementService {
|
|||||||
await this.blameRequestDbService.findByIdAndUpdate(req._id, {
|
await this.blameRequestDbService.findByIdAndUpdate(req._id, {
|
||||||
$set: { inquiries: req.inquiries },
|
$set: { inquiries: req.inquiries },
|
||||||
});
|
});
|
||||||
throw new HttpException(
|
this.throwCarBodyInquiryFailure(err);
|
||||||
"Car body inquiry failed",
|
|
||||||
HttpStatus.BAD_REQUEST,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Raw + mapped stored under vehicle
|
// Raw + mapped stored under vehicle
|
||||||
@@ -2041,10 +2048,7 @@ export class RequestManagementService {
|
|||||||
await this.blameRequestDbService.findByIdAndUpdate(req._id, {
|
await this.blameRequestDbService.findByIdAndUpdate(req._id, {
|
||||||
$set: { inquiries: req.inquiries },
|
$set: { inquiries: req.inquiries },
|
||||||
});
|
});
|
||||||
throw new HttpException(
|
this.throwCarBodyInquiryFailure(err);
|
||||||
"Car body inquiry failed",
|
|
||||||
HttpStatus.BAD_REQUEST,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3174,6 +3178,7 @@ export class RequestManagementService {
|
|||||||
);
|
);
|
||||||
} catch (er) {
|
} catch (er) {
|
||||||
this.logger.error(er);
|
this.logger.error(er);
|
||||||
|
if (er instanceof HttpException) throw er;
|
||||||
throw new InternalServerErrorException(
|
throw new InternalServerErrorException(
|
||||||
"Failed to update request with plate details.",
|
"Failed to update request with plate details.",
|
||||||
);
|
);
|
||||||
@@ -7369,6 +7374,7 @@ export class RequestManagementService {
|
|||||||
stepsToAdd.push(StepsEnum.F_addPlate);
|
stepsToAdd.push(StepsEnum.F_addPlate);
|
||||||
} catch (plateError) {
|
} catch (plateError) {
|
||||||
this.logger.error("Error processing first party plate:", plateError);
|
this.logger.error("Error processing first party plate:", plateError);
|
||||||
|
if (plateError instanceof HttpException) throw plateError;
|
||||||
throw new InternalServerErrorException(
|
throw new InternalServerErrorException(
|
||||||
"Failed to process first party plate information",
|
"Failed to process first party plate information",
|
||||||
);
|
);
|
||||||
@@ -9009,9 +9015,7 @@ export class RequestManagementService {
|
|||||||
{},
|
{},
|
||||||
err,
|
err,
|
||||||
);
|
);
|
||||||
throw new BadRequestException(
|
this.throwCarBodyInquiryFailure(err);
|
||||||
`CAR_BODY inquiry failed: ${err?.message || "استعلام در دسترس نیست"}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9861,9 +9865,7 @@ export class RequestManagementService {
|
|||||||
{},
|
{},
|
||||||
err,
|
err,
|
||||||
);
|
);
|
||||||
throw new BadRequestException(
|
this.throwCarBodyInquiryFailure(err);
|
||||||
`CAR_BODY VIN inquiry failed: ${err?.message || "استعلام در دسترس نیست"}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user