smartnode / telebot

Telegram Bot API in C
https://elmurod.net/telebot
Apache License 2.0
159 stars 35 forks source link

How to get detailed error description? #63

Open audi0615 opened 3 weeks ago

audi0615 commented 3 weeks ago

Hi,

Thanks for this great library.

I'm trying to get a detailed error description when an error occurs.

For testing purposes, I used an incorrect bot token and attempted to receive new messages as shown below:

int count = 0;
telebot_error_e ret;
telebot_message_t message;
telebot_update_type_e update_types[] = { TELEBOT_UPDATE_TYPE_MESSAGE };
telebot_update_t* updates;

ret = telebot_get_updates(handle, _offset, 100, 0, update_types, 0, &updates, &count);

The returned value is TELEBOT_ERROR_OPERATION_FAILED, but I need more detailed information, like what is printed in my debugging console:

[ERROR][telebot_core_curl_perform:145] HTTP error: 401 - "Unauthorized"

Is there any function to get error descriptions, such as telebot_get_error_description?

One more thing: currently, telebot_get_updates returns TELEBOT_ERROR_OPERATION_FAILED when there are no new messages. However, this makes it impossible to determine whether there are simply no messages or if an actual error has occurred.