Skip to content

Commit

Permalink
src: Improve default error logging of polling_error, webhook_error
Browse files Browse the repository at this point in the history
  • Loading branch information
BenAgencyCom committed Nov 18, 2017
1 parent 01a644f commit 4966083
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


* * *
Expand Down
6 changes: 6 additions & 0 deletions src/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ exports.BaseError = class BaseError extends Error {
super(`${code}: ${message}`);
this.code = code;
}
toJSON() {
return {
code: this.code,
message: this.message,
};
}
};


Expand Down
2 changes: 1 addition & 1 deletion src/telegramPolling.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})
Expand Down
2 changes: 1 addition & 1 deletion src/telegramWebHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 4966083

Please sign in to comment.