Skip to content

Commit

Permalink
Added try/catch to catch error when UPS site is down
Browse files Browse the repository at this point in the history
  • Loading branch information
bradlee96 committed Jul 22, 2021
1 parent 1ce4015 commit 3acb27f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/courier/ups.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 3acb27f

Please sign in to comment.