From 658f37f93d1a0c31c447adb3022cfd6cee4a1876 Mon Sep 17 00:00:00 2001 From: temomik Date: Fri, 1 Dec 2023 20:16:03 +0000 Subject: Added ability to handle error codes from all Api requests --- include/tgbot/TgException.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'include/tgbot/TgException.h') diff --git a/include/tgbot/TgException.h b/include/tgbot/TgException.h index e80711c..0fbda93 100644 --- a/include/tgbot/TgException.h +++ b/include/tgbot/TgException.h @@ -16,7 +16,21 @@ namespace TgBot { class TGBOT_API TgException : public std::runtime_error { public: - explicit TgException(const std::string& description); + + /** + * @brief Enum of possible errors from Api requests + */ + enum class ErrorCode : size_t { + Undefined = 0, + BadRequest = 400, Unauthorized = 401, + Forbidden = 403, NotFound = 404, + Flood = 402, Internal = 500, + HtmlResponse = 100, InvalidJson = 101 + }; + + explicit TgException(const std::string& description, ErrorCode errorCode); + + const ErrorCode errorCode; }; } -- cgit v1.2.3