mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-23 02:17: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:
parent
3221d647cc
commit
7e4cadb514
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user