src/polling: Fix bug #281

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:  https://github.com/yagop/node-telegram-bot-api/issues/281
  * Reported-by: @dimawebmaker
experimental
GochoMugo 9 years ago
parent 3221d647cc
commit 7e4cadb514
No known key found for this signature in database
GPG Key ID: 7B6A01CB57AA39E4
  1. 2
      src/telegramPolling.js

@ -146,7 +146,7 @@ class TelegramBotPolling {
return this.request('getUpdates', opts) return this.request('getUpdates', opts)
.catch(err => { .catch(err => {
if (err.response.statusCode === ANOTHER_WEB_HOOK_USED) { if (err.response && err.response.statusCode === ANOTHER_WEB_HOOK_USED) {
return this._unsetWebHook(); return this._unsetWebHook();
} }
throw err; throw err;

Loading…
Cancel
Save