Skip to content

Commit

Permalink
Error handling for failed requests (non 200 codes) (#21)
Browse files Browse the repository at this point in the history
* added proper error handling to the request to deal with timeouts and other failures based on the format of the responses used in the module
  • Loading branch information
driverjb authored and vbscott committed Jun 20, 2019
1 parent 69ba0f0 commit b39bc27
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ function _request_with_backoff (options, body, callback, waitSecs = 1) {
callback(buffer)
})
})
req.on('error', (err) => {
callback(JSON.stringify({ stat: 'ERROR', message: err.message }))
})
req.write(body)
req.end()
}
Expand Down

0 comments on commit b39bc27

Please sign in to comment.