refactor(sql): improved the return function to show data [] when not connected, prevents crashes
This commit is contained in:
@@ -163,28 +163,55 @@ export const printerStatus = async (p: any) => {
|
||||
resolve({ success: true, message: "Print cycle completed." });
|
||||
});
|
||||
|
||||
printer.on("error", async (error) => {
|
||||
// just going to say theres an error with the printer
|
||||
// as a safety destory it if its still there
|
||||
printer.on("end", () => {
|
||||
setTimeout(() => {
|
||||
if (!printer.destroyed) {
|
||||
createLog(
|
||||
"info",
|
||||
"printerState",
|
||||
"ocp",
|
||||
`${p.name}: was force closed, during normal cycle counting`
|
||||
);
|
||||
printer.destroy();
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
if (!errorCheck) {
|
||||
printer.on("error", async (error: any) => {
|
||||
// just going to say theres an error with the printer
|
||||
//console.log(error.code);
|
||||
if (error.code.includes("ETIMEDOUT") && !errorCheck) {
|
||||
createLog("error", "ocp", "ocp", `${p.name} is offline`);
|
||||
|
||||
await printerUpdate(p, 9);
|
||||
errorCheck = true;
|
||||
printer.end();
|
||||
|
||||
resolve({
|
||||
success: false,
|
||||
message: "The printer is offline.",
|
||||
});
|
||||
}
|
||||
if (!error.code.includes("ETIMEDOUT") && !errorCheck) {
|
||||
createLog(
|
||||
"error",
|
||||
"ocp",
|
||||
"ocp",
|
||||
`${p.name} encountered an error: ${error}`
|
||||
);
|
||||
|
||||
await printerUpdate(p, 7);
|
||||
errorCheck = true;
|
||||
|
||||
// send log data
|
||||
// fake line
|
||||
printer.end();
|
||||
resolve({
|
||||
success: false,
|
||||
message: "There was an error with the printer.",
|
||||
});
|
||||
}
|
||||
|
||||
await printerUpdate(p, 7);
|
||||
errorCheck = true;
|
||||
|
||||
// send log data
|
||||
// fake line
|
||||
printer.end();
|
||||
resolve({
|
||||
success: false,
|
||||
message: "There was an error with the printer.",
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -230,13 +257,13 @@ export const autoLabelingStats = async (p: any) => {
|
||||
|
||||
printer.on("error", async (error) => {
|
||||
// just going to say theres an error with the printer
|
||||
|
||||
console.log(error);
|
||||
if (!errorCheck) {
|
||||
createLog(
|
||||
"error",
|
||||
"ocp",
|
||||
"ocp",
|
||||
`${p.name} encountered an error: ${error}`
|
||||
`${p.name}, encountered an error: ${error}`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user