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:
parent
6263dcb007
commit
8c965d3a14
@ -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)
|
||||
|
||||
|
||||
* * *
|
||||
|
@ -10,6 +10,12 @@ exports.BaseError = class BaseError extends Error {
|
||||
super(`${code}: ${message}`);
|
||||
this.code = code;
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
code: this.code,
|
||||
message: this.message,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -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;
|
||||
})
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user