Skip to content

Commit

Permalink
src/polling: Fix bug #281
Browse files Browse the repository at this point in the history
Bug:

  On certain errors, during polling, cause the following error to be
  thrown:

    TypeError: Cannot read property 'statusCode' of undefined

  This is caused when we try to access the 'response' property on
  the error object in the error handler (`catch(error)`). It goes
  missing when the error was fatal, for example, network error, thus
  no server response available.

References:

  * Issue #281:  #281
  * Reported-by: @dimawebmaker
  • Loading branch information
GochoMugo committed Feb 8, 2017
1 parent 3221d64 commit 7e4cadb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/telegramPolling.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class TelegramBotPolling {

return this.request('getUpdates', opts)
.catch(err => {
if (err.response.statusCode === ANOTHER_WEB_HOOK_USED) {
if (err.response && err.response.statusCode === ANOTHER_WEB_HOOK_USED) {
return this._unsetWebHook();
}
throw err;
Expand Down

0 comments on commit 7e4cadb

Please sign in to comment.