pengrad / java-telegram-bot-api

Telegram Bot API for Java
https://core.telegram.org/bots
Apache License 2.0
1.79k stars 372 forks source link

API errors handling #156

Closed Sallatik closed 5 years ago

Sallatik commented 5 years ago

It seems like this library does not bother handling error response returned by telegram. For example, bot.execute(new SendMessage(666, "Hello!") will simply return an empty response. (Except if your bot has a chat with id=666, of course) Thus, all error messages are lost and it is nearly impossible to react to those errors in any way. Shall there be some kind of error handling mechanism added, probably using checked exceptions?

futpib commented 5 years ago

Doesn't this provide what you ask for? https://github.com/pengrad/java-telegram-bot-api/blob/master/README.md#other-requests

You could use errorCode and description.

pengrad commented 5 years ago

Thanks @futpib Yes, every response has methods:

boolean isOk()
int errorCode()
String description()
ResponseParameters parameters()
Sallatik commented 5 years ago

Now I see, sorry for bothering, I should be more careful reading docs