Merged in feature/IO-3629-PostBatchWip-rtn-1-Catch (pull request #3163)
IO-3629 PostBatchWip Rtn != 0 error Approved-by: Dave Richer
This commit is contained in:
@@ -334,30 +334,48 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
||||
socket.emit("export-success", JobData.id);
|
||||
} else {
|
||||
//There was something wrong. Throw an error to trigger clean up.
|
||||
//throw new Error("Error posting DMS Batch Transaction");
|
||||
const batchPostError = new Error(DmsBatchTxnPost.sendline || "Error posting DMS Batch Transaction");
|
||||
batchPostError.errorData = { DMSTransHeader, DmsBatchTxnPost };
|
||||
throw batchPostError;
|
||||
}
|
||||
} catch {
|
||||
} catch (error) {
|
||||
//Clean up the transaction and insert a faild error code
|
||||
// //Get the error code
|
||||
CreateFortellisLogEvent(socket, "DEBUG", `{6.1} Getting errors for Transaction ID ${DMSTransHeader.transID}`);
|
||||
|
||||
const DmsError = await QueryDmsErrWip({ socket, redisHelpers, JobData });
|
||||
// //Delete the transaction
|
||||
let dmsErrors = [];
|
||||
try {
|
||||
const DmsError = await QueryDmsErrWip({ socket, redisHelpers, JobData });
|
||||
dmsErrors = Array.isArray(DmsError?.errMsg) ? DmsError.errMsg.filter((e) => e !== null && e !== "") : [];
|
||||
|
||||
dmsErrors.forEach((e) => {
|
||||
CreateFortellisLogEvent(socket, "ERROR", `Error encountered in posting transaction => ${e} `);
|
||||
});
|
||||
} catch (queryError) {
|
||||
CreateFortellisLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`{6.1} Unable to read ErrWIP for Transaction ID ${DMSTransHeader.transID}: ${queryError.message}`
|
||||
);
|
||||
}
|
||||
|
||||
//Delete the transaction, even if querying ErrWIP fails.
|
||||
CreateFortellisLogEvent(socket, "DEBUG", `{6.2} Deleting Transaction ID ${DMSTransHeader.transID}`);
|
||||
try {
|
||||
await DeleteDmsWip({ socket, redisHelpers, JobData });
|
||||
} catch (cleanupError) {
|
||||
CreateFortellisLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`{6.2} Failed cleanup for Transaction ID ${DMSTransHeader.transID}: ${cleanupError.message}`
|
||||
);
|
||||
}
|
||||
|
||||
await DeleteDmsWip({ socket, redisHelpers, JobData });
|
||||
|
||||
DmsError.errMsg.map(
|
||||
(e) =>
|
||||
e !== null &&
|
||||
e !== "" &&
|
||||
CreateFortellisLogEvent(socket, "ERROR", `Error encountered in posting transaction => ${e} `)
|
||||
);
|
||||
await InsertFailedExportLog({
|
||||
socket,
|
||||
JobData,
|
||||
error: DmsError.errMsg
|
||||
});
|
||||
if (!error.errorData || typeof error.errorData !== "object") {
|
||||
error.errorData = {};
|
||||
}
|
||||
error.errorData.issues = dmsErrors.length ? dmsErrors : [error.message];
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user