Skip to content

Commit

Permalink
TgException: Use int for ErrorCode enum base
Browse files Browse the repository at this point in the history
  • Loading branch information
Royna2544 committed Sep 21, 2024
1 parent bf4ebe0 commit bc3b1f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/tgbot/TgException.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <string>
#include <stdexcept>
#include <cstdint>

namespace TgBot {

Expand All @@ -20,7 +21,7 @@ class TGBOT_API TgException : public std::runtime_error {
/**
* @brief Enum of possible errors from Api requests
*/
enum class ErrorCode : size_t {
enum class ErrorCode : std::int32_t {
Undefined = 0,
BadRequest = 400, Unauthorized = 401,
Forbidden = 403, NotFound = 404,
Expand Down
2 changes: 1 addition & 1 deletion src/Api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2791,7 +2791,7 @@ Api::sendRequest(const std::string &method,
return result["result"];
} else {
std::string message = result["description"].asString();
size_t errorCode = result["error_code"].as<size_t>();
int errorCode = result["error_code"].as<int>();

throw TgException(message,
static_cast<TgException::ErrorCode>(errorCode));
Expand Down

0 comments on commit bc3b1f1

Please sign in to comment.