Skip to content

Commit

Permalink
fix: handle non-http errors correctly (#375) (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
silentjohnny authored Oct 7, 2023
1 parent 3de45c6 commit 07ee1af
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,16 @@ Sender.prototype.sendNoRetry = function(message, recipient, callback) {
(err) => {
const { response: res } = err;

if (res.status === 401) {
debug('Unauthorized (401). Check that your API token is correct.');
return callback(res.status);
}

if (res.status >= 500) {
debug('GCM service is unavailable (500)');
return callback(res.status);
if (res) {
if (res.status === 401) {
debug('Unauthorized (401). Check that your API token is correct.');
return callback(res.status);
}

if (res.status >= 500) {
debug('GCM service is unavailable (500)');
return callback(res.status);
}
}

return callback(err);
Expand Down

0 comments on commit 07ee1af

Please sign in to comment.