revisi handle error
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"base_url": "http://riau/one-api/",
|
||||
"base_url": "http://<isi sesuai cabang>/one-api/",
|
||||
"schedule": ["0 5,12,17 * * *"],
|
||||
"delay": 5,
|
||||
"row_per_batch": 50
|
||||
|
||||
@@ -20,8 +20,16 @@ export const getBranch = async () => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -43,8 +51,16 @@ export const getMgmMcu = async () => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -69,8 +85,16 @@ export const uploadMgmMcu = async (branch: any, data: any) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -92,8 +116,16 @@ export const getMgmHeader = async (mgmMcuID: string) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -116,8 +148,16 @@ export const getTop3Kelainan = async (mgmMcuID: string) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -139,8 +179,16 @@ export const getMcuorder = async (mgmMcuID: string) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -163,8 +211,16 @@ export const getAntropometri = async (mgmMcuID: string) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -187,8 +243,16 @@ export const getMcuSnapshotNote = async (mgmMcuID: string) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -210,8 +274,16 @@ export const getMgmMou = async () => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -236,8 +308,16 @@ export const uploadMgmHeader = async (branch: any, data: any) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -260,8 +340,16 @@ export const getMgmDetail = async (mgmHeaderID: any) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -284,8 +372,16 @@ export const getMgmRiwayat = async (mgmHeaderID: any) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -336,8 +432,16 @@ export const uploadMgmRiwayat = async (branch: any, data: any) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -362,8 +466,16 @@ export const uploadMgmMou = async (branch: any, data: any) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -389,8 +501,16 @@ export const uploadTop3Kelainan = async (branch: any, data: any) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -416,8 +536,16 @@ export const uploadMcuOrder = async (branch: any, data: any) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -443,8 +571,16 @@ export const uploadAntropometri = async (branch: any, data: any) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -470,8 +606,16 @@ export const uploadMcuSnapshotNote = async (branch: any, data: any) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -499,8 +643,16 @@ export const uploadMgmCompany = async (branchCode: any, mgmMcuID: any) => {
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
logging.error(NAME_SPACE, e.response?.data.toString());
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.response?.data.toString(),
|
||||
};
|
||||
} else if (e instanceof Error) {
|
||||
logging.error(NAME_SPACE, e.message);
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -58,6 +58,7 @@ async function Upload() {
|
||||
logging.info(NAME_SPACE, "Starting Job Upload national" + VERSION);
|
||||
logging.info(NAME_SPACE, "START GET BRANCH");
|
||||
var respbranch = await getBranch();
|
||||
// console.log(respbranch);
|
||||
if (respbranch["status"] != "OK") {
|
||||
logging.error(NAME_SPACE, "\t Error", respbranch);
|
||||
} else {
|
||||
@@ -147,8 +148,8 @@ async function Upload() {
|
||||
}
|
||||
logging.info(NAME_SPACE, "\t END JOB GET MGM HEADER");
|
||||
logging.info(NAME_SPACE, "\t ----------");
|
||||
// logging.info(NAME_SPACE, "\t wait 1s");
|
||||
// await delay(1000);
|
||||
logging.info(NAME_SPACE, "\t wait 1s");
|
||||
await delay(1000);
|
||||
logging.info(NAME_SPACE, "\t START UPLOAD MGM HEADER");
|
||||
for (let j = 0; j < mgmHeaderList.length; j++) {
|
||||
let headerNumber = j + 1;
|
||||
@@ -181,8 +182,8 @@ async function Upload() {
|
||||
);
|
||||
|
||||
logging.info(NAME_SPACE, "\t\t ----------");
|
||||
// logging.info(NAME_SPACE, "\t\t wait 1s");
|
||||
// await delay(600);
|
||||
logging.info(NAME_SPACE, "\t\t wait 1s");
|
||||
await delay(500);
|
||||
|
||||
//GET MGM DETAIL
|
||||
logging.info(NAME_SPACE, "\t\t\t START GET MGM DETAIL");
|
||||
@@ -261,8 +262,8 @@ async function Upload() {
|
||||
);
|
||||
|
||||
logging.info(NAME_SPACE, "\t\t\t ----------");
|
||||
// logging.info(NAME_SPACE, "\t\t\t wait 1s");
|
||||
// await delay(1000);
|
||||
logging.info(NAME_SPACE, "\t\t\t wait 1s");
|
||||
await delay(700);
|
||||
}
|
||||
}
|
||||
logging.info(NAME_SPACE, "\t END UPLOAD MGM HEADER");
|
||||
|
||||
Reference in New Issue
Block a user