2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-22 18:07:16 +00:00

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
This commit is contained in:
GochoMugo 2017-02-08 11:44:42 +03:00
parent 3221d647cc
commit 7e4cadb514
No known key found for this signature in database
GPG Key ID: 7B6A01CB57AA39E4

View File

@ -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;