Merged in feature/IO-2924-Refactor-Production-board-to-use-Socket-Provider (pull request #1798)

Add try catch to PBS/CDK and main.
This commit is contained in:
Patrick Fic
2024-09-27 16:25:54 +00:00
3 changed files with 42 additions and 27 deletions

View File

@@ -211,4 +211,11 @@ const main = async () => {
}; };
// Start server // Start server
main(); try {
main();
} catch (error) {
logger.log(`Main-API-Error: Something was not caught in the application.`, "error", "api", null, {
error: error.message,
errorjson: JSON.stringify(error)
});
}

View File

@@ -602,18 +602,22 @@ async function MarkJobExported(socket, jobid) {
} }
async function InsertFailedExportLog(socket, error) { async function InsertFailedExportLog(socket, error) {
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {}); try {
const result = await client const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {});
.setHeaders({ Authorization: `Bearer ${socket.handshake.auth.token}` }) const result = await client
.request(queries.INSERT_EXPORT_LOG, { .setHeaders({ Authorization: `Bearer ${socket.handshake.auth.token}` })
log: { .request(queries.INSERT_EXPORT_LOG, {
bodyshopid: socket.JobData.bodyshop.id, log: {
jobid: socket.JobData.id, bodyshopid: socket.JobData.bodyshop.id,
successful: false, jobid: socket.JobData.id,
message: [error], successful: false,
useremail: socket.user.email message: [error],
} useremail: socket.user.email
}); }
});
return result; return result;
} catch (error2) {
CdkBase.createLogEvent(socket, "ERROR", `Error in InsertFailedExportLog - ${error} - ${JSON.stringify(error2)}`);
}
} }

View File

@@ -986,18 +986,22 @@ async function MarkJobExported(socket, jobid) {
} }
async function InsertFailedExportLog(socket, error) { async function InsertFailedExportLog(socket, error) {
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {}); try {
const result = await client const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {});
.setHeaders({ Authorization: `Bearer ${socket.handshake.auth.token}` }) const result = await client
.request(queries.INSERT_EXPORT_LOG, { .setHeaders({ Authorization: `Bearer ${socket.handshake.auth.token}` })
log: { .request(queries.INSERT_EXPORT_LOG, {
bodyshopid: socket.JobData.bodyshop.id, log: {
jobid: socket.JobData.id, bodyshopid: socket.JobData.bodyshop.id,
successful: false, jobid: socket.JobData.id,
message: [error], successful: false,
useremail: socket.user.email message: [error],
} useremail: socket.user.email
}); }
});
return result; return result;
} catch (error2) {
CdkBase.createLogEvent(socket, "ERROR", `Error in InsertFailedExportLog - ${error} - ${JSON.stringify(error2)}`);
}
} }