Skip to content

Commit

Permalink
♻️ Add logs for upptime/upptime#150
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Jan 1, 2021
1 parent 59a35f0 commit eaad729
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/helpers/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ export const curl = (
curl.setOpt("HEADER", 1);
curl.setOpt("VERBOSE", false);
curl.setOpt("CUSTOMREQUEST", method);
curl.on("error", () => {
curl.on("error", (error) => {
curl.close();
console.log("Got an error (on error)", error);
return resolve({ httpCode: 0, totalTime: 0, data: "" });
});
curl.on("end", (_, data) => {
Expand All @@ -39,8 +40,10 @@ export const curl = (
totalTime = Number(curl.getInfo("TOTAL_TIME"));
} catch (error) {
curl.close();
console.log("Got an error (on end)", error);
return resolve({ httpCode, totalTime, data });
}
if (httpCode === 0 || totalTime === 0) console.log("Didn't get an error but got 0s");
return resolve({ httpCode, totalTime, data });
});
curl.perform();
Expand Down

0 comments on commit eaad729

Please sign in to comment.