Retain inquiry audit context on failure

This commit is contained in:
SepehrYahyaee
2026-09-13 11:42:20 +03:30
parent fe22e69351
commit 287978a555
3 changed files with 67 additions and 20 deletions

View File

@@ -421,6 +421,8 @@ export async function runPlateInquiryWithFallback<T>(options: {
plateKind: "CURRENT" | "PREVIOUS";
attempts: Array<{
plateKind: "CURRENT" | "PREVIOUS";
plate: InquiryVehicleInputDto["currentPlate"];
vin?: string;
succeeded: boolean;
usable?: boolean;
error?: string;
@@ -432,6 +434,8 @@ export async function runPlateInquiryWithFallback<T>(options: {
let lastError: unknown;
const attempts: Array<{
plateKind: "CURRENT" | "PREVIOUS";
plate: InquiryVehicleInputDto["currentPlate"];
vin?: string;
succeeded: boolean;
usable?: boolean;
error?: string;
@@ -446,6 +450,8 @@ export async function runPlateInquiryWithFallback<T>(options: {
if (!usable) {
attempts.push({
plateKind: candidate.kind,
plate: candidate.plate,
...(options.vehicle?.vin ? { vin: options.vehicle.vin } : {}),
succeeded: true,
usable: false,
});
@@ -464,6 +470,8 @@ export async function runPlateInquiryWithFallback<T>(options: {
}
attempts.push({
plateKind: candidate.kind,
plate: candidate.plate,
...(options.vehicle?.vin ? { vin: options.vehicle.vin } : {}),
succeeded: true,
usable: true,
});
@@ -477,6 +485,8 @@ export async function runPlateInquiryWithFallback<T>(options: {
if (!alreadyRecorded) {
attempts.push({
plateKind: candidate.kind,
plate: candidate.plate,
...(options.vehicle?.vin ? { vin: options.vehicle.vin } : {}),
succeeded: false,
error: error instanceof Error ? error.message : String(error),
});