From 3acb27f1031c6b261a5131715148cf2615cb0591 Mon Sep 17 00:00:00 2001 From: Brad Date: Thu, 22 Jul 2021 11:41:41 -0500 Subject: [PATCH] Added try/catch to catch error when UPS site is down --- lib/courier/ups.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/courier/ups.js b/lib/courier/ups.js index 9a94e65..fc2b36f 100644 --- a/lib/courier/ups.js +++ b/lib/courier/ups.js @@ -53,7 +53,11 @@ module.exports = function (opts) { } var token = parser.token(res.headers['set-cookie'] || []) req(tracking.detail(token), function (err, res, body) { - var response = JSON.parse(body) + try { + var response = JSON.parse(body) + } catch (error) { + return cb(error) + } if (response.statusCode !== '200') { return cb(response.statusText) }