feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Expanded Logs / Formatting change

This commit is contained in:
Dave
2025-11-12 17:01:54 -05:00
parent 556cd993b9
commit 90f653c0b7
13 changed files with 444 additions and 254 deletions

View File

@@ -1,6 +1,9 @@
// Map RR vendor/status failures into user-friendly messages the FE can show.
function parseVendorStatusCode(err) {
/**
* Parse vendor status code from various possible locations in the error object.
* @param err
* @returns {number|null}
*/
const parseVendorStatusCode = (err) => {
// Prefer explicit numeric props when available
const codeProp = err?.code ?? err?.statusCode ?? err?.meta?.status?.StatusCode ?? err?.status?.StatusCode;
const num = Number(codeProp);
@@ -9,14 +12,14 @@ function parseVendorStatusCode(err) {
// Fallback: parse from message text (e.g., "... 507 CANNOT EXCEED ...")
const m = String(err?.message || "").match(/\b(\d{3})\b/);
return m ? Number(m[1]) : null;
}
};
/**
* Classify RR vendor errors into a small set of stable codes/messages for the FE.
* @param {any} err
* @returns {{vendorStatusCode:number|null, errorCode:string, title:string, friendlyMessage:string, severity:'info'|'warning'|'error', canRetry:boolean}}
*/
function classifyRRVendorError(err) {
const classifyRRVendorError = (err) => {
const code = parseVendorStatusCode(err);
const rawMsg = String(err?.meta?.status?.Message || err?.status?.Message || err?.message || "").toUpperCase();
@@ -43,6 +46,6 @@ function classifyRRVendorError(err) {
severity: "error",
canRetry: true
};
}
};
module.exports = { classifyRRVendorError };