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