Improved error logging.

This commit is contained in:
Patrick Fic
2025-09-18 11:32:48 -07:00
parent c8771275ce
commit 517c30787d

View File

@@ -215,46 +215,55 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, ioHelpers, sele
const DMSBatchTxn = await InsertDmsBatchWip({ socket, redisHelpers, JobData });
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DMSBatchTxn, DMSBatchTxn, defaultFortellisTTL);
CreateFortellisLogEvent(
socket,
"DEBUG",
`{6} Attempting to post Transaction with ID ${DMSTransHeader.transID}`
);
const DmsBatchTxnPost = await PostDmsBatchWip({ socket, redisHelpers, JobData });
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DmsBatchTxnPost, DmsBatchTxnPost, defaultFortellisTTL);
if (DmsBatchTxnPost.rtnCode === "0") { //TODO: Validate this is a string and not #
//something
CreateFortellisLogEvent(socket, "DEBUG", `{6} Successfully posted transaction to DMS.`);
await MarkJobExported({ socket, jobid: JobData.id });
CreateFortellisLogEvent(socket, "DEBUG", `{5} Updating Service Vehicle History.`);
const DMSVehHistory = await InsertServiceVehicleHistory({ socket, redisHelpers, JobData });
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DMSVehHistory, DMSVehHistory, defaultFortellisTTL);
socket.emit("export-success", JobData.id);
} else {
//Get the error code
if (DMSBatchTxn.rtnCode === "0") {
CreateFortellisLogEvent(
socket,
"DEBUG",
`{6.1} Getting errors for Transaction ID ${DMSTransHeader.transID}`
`{6} Attempting to post Transaction with ID ${DMSTransHeader.transID}`
);
const DmsBatchTxnPost = await PostDmsBatchWip({ socket, redisHelpers, JobData });
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DmsBatchTxnPost, DmsBatchTxnPost, defaultFortellisTTL);
if (DmsBatchTxnPost.rtnCode === "0") { //TODO: Validate this is a string and not #
//something
CreateFortellisLogEvent(socket, "DEBUG", `{6} Successfully posted transaction to DMS.`);
await MarkJobExported({ socket, jobid: JobData.id });
CreateFortellisLogEvent(socket, "DEBUG", `{5} Updating Service Vehicle History.`);
const DMSVehHistory = await InsertServiceVehicleHistory({ socket, redisHelpers, JobData });
await setSessionTransactionData(socket.id, getTransactionType(jobid), FortellisCacheEnums.DMSVehHistory, DMSVehHistory, defaultFortellisTTL);
socket.emit("export-success", JobData.id);
} else {
//Get the error code
CreateFortellisLogEvent(
socket,
"DEBUG",
`{6.1} Getting errors for Transaction ID ${DMSTransHeader.transID}`
);
// socket.DmsError = await QueryDmsErrWip(socket);
// //Delete the transaction
// CdkBase.createLogEvent(socket, "DEBUG", `{ 6.2 } Deleting Transaction ID ${ socket.DMSTransHeader.transID } `);
// socket.DmsBatchTxnPost = await DeleteDmsWip(socket);
// socket.DmsError.errMsg
// .split("|")
// .map(
// (e) =>
// e !== null &&
// e !== "" &&
// CdkBase.createLogEvent(socket, "ERROR", `Error(s) encountered in posting transaction.${ e } `)
// );
}
} else {
//Posting transaction failed.
CreateFortellisLogEvent(
socket,
"ERROR",
`DMS Batch Return code was not successful: ${DMSBatchTxn.rtnCode} - ${DMSBatchTxn.sendline}`
);
// socket.DmsError = await QueryDmsErrWip(socket);
// //Delete the transaction
// CdkBase.createLogEvent(socket, "DEBUG", `{ 6.2 } Deleting Transaction ID ${ socket.DMSTransHeader.transID } `);
// socket.DmsBatchTxnPost = await DeleteDmsWip(socket);
// socket.DmsError.errMsg
// .split("|")
// .map(
// (e) =>
// e !== null &&
// e !== "" &&
// CdkBase.createLogEvent(socket, "ERROR", `Error(s) encountered in posting transaction.${ e } `)
// );
}
} catch (error) {
// CdkBase.createLogEvent(socket, "ERROR", `Error encountered in CdkSelectedCustomer.${ error } `);