refactor(puchase): changes how the error handling works so a better email can be sent
This commit is contained in:
@@ -20,8 +20,8 @@ export const gpReqCheck = async (data: GpStatus[]) => {
|
||||
module: "purchase",
|
||||
subModule: "query",
|
||||
message: `Error getting alpla purchase info`,
|
||||
data: [gpReqCheck.message],
|
||||
notify: false,
|
||||
data: gpReqCheck.message as any,
|
||||
notify: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export const gpReqCheck = async (data: GpStatus[]) => {
|
||||
const result = await gpQuery(
|
||||
gpReqCheck.query.replace(
|
||||
"[reqsToCheck]",
|
||||
data.map((r) => `'${r.req}'`).join(", ") ?? "",
|
||||
data.map((r) => `'${r.req}'`).join(", ") ?? "xo",
|
||||
),
|
||||
"Get req info",
|
||||
);
|
||||
@@ -55,7 +55,7 @@ export const gpReqCheck = async (data: GpStatus[]) => {
|
||||
[Requisition Number] as req
|
||||
,case when [Workflow Status] = 'recall' then 'returned' else [Workflow Status] end as approvedStatus
|
||||
--,*
|
||||
from [dbo].[PurchaseRequisitions] where [Requisition Number] in (${missing1Reqs.map((r) => `'${r}'`).join(", ")})`,
|
||||
from [dbo].[PurchaseRequisitions] where [Requisition Number] in (${missing1Reqs.map((r) => `'${r}'`).join(", ") ?? "xo"})`,
|
||||
"validate req is not in recall",
|
||||
);
|
||||
|
||||
@@ -76,7 +76,7 @@ export const gpReqCheck = async (data: GpStatus[]) => {
|
||||
,PONUMBER
|
||||
,reqStatus='converted'
|
||||
,*
|
||||
from alpla.dbo.sop60100 (nolock) where sopnumbe in (${missing2Reqs.map((r) => `'${r}'`).join(", ")})`,
|
||||
from alpla.dbo.sop60100 (nolock) where sopnumbe in (${missing2Reqs.map((r) => `'${r}'`).join(", ") ?? "xo"})`,
|
||||
"Get release info",
|
||||
);
|
||||
|
||||
@@ -111,7 +111,15 @@ export const gpReqCheck = async (data: GpStatus[]) => {
|
||||
}));
|
||||
|
||||
return updateData;
|
||||
} catch (error) {
|
||||
log.error({ stack: error });
|
||||
} catch (error: any) {
|
||||
return returnFunc({
|
||||
success: false,
|
||||
level: "error",
|
||||
module: "purchase",
|
||||
subModule: "gpChecks",
|
||||
message: error.message,
|
||||
data: error.stack as any,
|
||||
notify: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,8 +39,8 @@ export const monitorAlplaPurchase = async () => {
|
||||
module: "purchase",
|
||||
subModule: "query",
|
||||
message: `Error getting alpla purchase info`,
|
||||
data: [sqlQuery.message],
|
||||
notify: false,
|
||||
data: sqlQuery.message as any,
|
||||
notify: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ export const monitorAlplaPurchase = async () => {
|
||||
|
||||
if (error) {
|
||||
log.error(
|
||||
{ error },
|
||||
{ error, notify: true },
|
||||
"There was an error adding alpla purchase history",
|
||||
);
|
||||
}
|
||||
@@ -86,8 +86,10 @@ export const monitorAlplaPurchase = async () => {
|
||||
await delay(500);
|
||||
}
|
||||
} catch (e) {
|
||||
log.error({ error: e }, "Error occurred while running the monitor job");
|
||||
log.error({ error: e }, "Error occurred while running the monitor job");
|
||||
log.error(
|
||||
{ error: e, notify: true },
|
||||
"Error occurred while running the monitor job",
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -104,7 +106,7 @@ export const monitorAlplaPurchase = async () => {
|
||||
// if theres no reqs just end meow
|
||||
if (errorReq) {
|
||||
log.error(
|
||||
{ stack: errorReq },
|
||||
{ stack: errorReq, notify: true },
|
||||
"There was an error getting history data",
|
||||
);
|
||||
return;
|
||||
|
||||
@@ -33,7 +33,8 @@ interface Data<T = unknown[]> {
|
||||
| "delete"
|
||||
| "printing"
|
||||
| "gpSql"
|
||||
| "email";
|
||||
| "email"
|
||||
| "gpChecks";
|
||||
level: "info" | "error" | "debug" | "fatal";
|
||||
message: string;
|
||||
room?: string;
|
||||
|
||||
Reference in New Issue
Block a user