2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-28 21:07:39 +00:00

src: Improve default error logging of polling_error, webhook_error

References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/377
This commit is contained in:
GochoMugo 2017-11-18 23:21:52 +03:00
parent 6263dcb007
commit 8c965d3a14
No known key found for this signature in database
GPG Key ID: 7B6A01CB57AA39E4
4 changed files with 13 additions and 3 deletions

View File

@ -11,11 +11,15 @@ Added:
friends e.g. `text`, `audio`, etc.) (#409) (by @jlsjonas, @GochoMugo)
1. Add support for Node.js v9 (by @GochoMugo)
1. Document *TelegramBot.errors*, *TelegramBot.messageTypes* (by @GochoMugo)
1. Fix game example (by @MCSH)
Changed:
1. Update *TelegramBot#answerCallbackQuery()* signature (by @GochoMugo)
1. Improve default error logging of `polling_error` and `webhook_error`
Fixed:
1. Fix game example (by @MCSH)
* * *

View File

@ -10,6 +10,12 @@ exports.BaseError = class BaseError extends Error {
super(`${code}: ${message}`);
this.code = code;
}
toJSON() {
return {
code: this.code,
message: this.message,
};
}
};

View File

@ -102,7 +102,7 @@ class TelegramBotPolling {
if (this.bot.listeners('polling_error').length) {
this.bot.emit('polling_error', err);
} else {
console.error(err); // eslint-disable-line no-console
console.error('error: [polling_error] %j', err); // eslint-disable-line no-console
}
return null;
})

View File

@ -97,7 +97,7 @@ class TelegramBotWebHook {
*/
_error(error) {
if (!this.bot.listeners('webhook_error').length) {
return console.error(error); // eslint-disable-line no-console
return console.error('error: [webhook_error] %j', error); // eslint-disable-line no-console
}
return this.bot.emit('webhook_error', error);
}