summaryrefslogtreecommitdiff
path: root/include/tgbot/TgException.h
blob: 0fbda9391550c784d9bf269a1cc5a7783276c23c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef TGBOT_TGEXCEPTION_H
#define TGBOT_TGEXCEPTION_H

#include "tgbot/export.h"

#include <string>
#include <stdexcept>

namespace TgBot {

/**
 * @brief Exception type which is only thrown when Telegram refuses API request.
 *
 * @ingroup general
 */
class TGBOT_API TgException : public std::runtime_error {

public:

    /**
     * @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;
};

}

#endif //TGBOT_TGEXCEPTION_H