Allow module consumers to deal with Promise rejections themselves #38

Merged
laurynas-karvelis merged 2 commits from master into master 2018-02-05 18:15:02 +00:00
laurynas-karvelis commented 2018-02-05 14:44:31 +00:00 (Migrated from github.com)

Hi again mdibaiee,

I've noticed recently that should Telegram's https://api.telegram.org/bot endpoint return 502 or similar error, the current implementation spews entire error straight to console.error. Which, in my opinion, isn't the most elegant solution, as the error object itself contains a lot of recursive objects and makes entire error log impossible to read and pollutes entire logger (if one is used, say, pm2 native log collector).

Hence I propose a solution that skips spewing error directly into console.error, but rejects bot.send promise instead allowing module consumer to deal with rejections themselves.

Also, provided catch statement in src/index.js eats up the error and continues the promise chain, which on it's own creates potential false-positives.

Hope this makes sense :)

Hi again mdibaiee, I've noticed recently that should Telegram's https://api.telegram.org/bot endpoint return 502 or similar error, the current implementation spews entire error straight to console.error. Which, in my opinion, isn't the most elegant solution, as the error object itself contains a lot of recursive objects and makes entire error log impossible to read and pollutes entire logger (if one is used, say, pm2 native log collector). Hence I propose a solution that skips spewing error directly into console.error, but rejects bot.send promise instead allowing module consumer to deal with rejections themselves. Also, provided catch statement in src/index.js eats up the error and continues the promise chain, which on it's own creates potential false-positives. Hope this makes sense :)
mdibaiee commented 2018-02-05 18:14:54 +00:00 (Migrated from github.com)

@laurynas-karvelis this is great! I surely haven't had thought of this at the time of writing the API. Thanks a lot Laurynas!

@laurynas-karvelis this is great! I surely haven't had thought of this at the time of writing the API. Thanks a lot Laurynas!
mdibaiee commented 2018-02-05 18:17:15 +00:00 (Migrated from github.com)

As this is a breaking change, I introduced a new major version.

Published as node-telegram-api@1.0.0.

As this is a breaking change, I introduced a new major version. Published as `node-telegram-api@1.0.0.`
laurynas-karvelis commented 2018-02-06 14:20:33 +00:00 (Migrated from github.com)

Thank you mdibaiee! 👍

Thank you mdibaiee! :+1:
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: thereadme/node-telegram-api#38
No description provided.