IO-3629 PostBatchWip Rtn != 0 error
Signed-off-by: Allan Carr <allan@imexsystems.ca>
This commit is contained in:
@@ -334,30 +334,48 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
|
|||||||
socket.emit("export-success", JobData.id);
|
socket.emit("export-success", JobData.id);
|
||||||
} else {
|
} else {
|
||||||
//There was something wrong. Throw an error to trigger clean up.
|
//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
|
//Clean up the transaction and insert a faild error code
|
||||||
// //Get the error code
|
// //Get the error code
|
||||||
CreateFortellisLogEvent(socket, "DEBUG", `{6.1} Getting errors for Transaction ID ${DMSTransHeader.transID}`);
|
CreateFortellisLogEvent(socket, "DEBUG", `{6.1} Getting errors for Transaction ID ${DMSTransHeader.transID}`);
|
||||||
|
|
||||||
const DmsError = await QueryDmsErrWip({ socket, redisHelpers, JobData });
|
let dmsErrors = [];
|
||||||
// //Delete the transaction
|
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}`);
|
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 });
|
if (!error.errorData || typeof error.errorData !== "object") {
|
||||||
|
error.errorData = {};
|
||||||
DmsError.errMsg.map(
|
}
|
||||||
(e) =>
|
error.errorData.issues = dmsErrors.length ? dmsErrors : [error.message];
|
||||||
e !== null &&
|
throw error;
|
||||||
e !== "" &&
|
|
||||||
CreateFortellisLogEvent(socket, "ERROR", `Error encountered in posting transaction => ${e} `)
|
|
||||||
);
|
|
||||||
await InsertFailedExportLog({
|
|
||||||
socket,
|
|
||||||
JobData,
|
|
||||||
error: DmsError.errMsg
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user