summaryrefslogtreecommitdiffstatshomepage
path: root/cgitrc
stat options
Period:
Authors:

Commits per author per week (path 'cgitrc')

AuthorW50 2024W51 2024W52 2024W01 2025Total
Total00000
'n14' href='#n14'>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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
/*  This file is part of mastodonpp.
 *  Copyright © 2020 tastytea <tastytea@tastytea.de>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as published by
 *  the Free Software Foundation, version 3.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef MASTODONPP_EXCEPTIONS_HPP
#define MASTODONPP_EXCEPTIONS_HPP

#include <curl/curl.h>

#include <cstdint>
#include <exception>
#include <string>

namespace mastodonpp
{

using std::uint16_t;
using std::exception;
using std::string;

/*!
 *  @brief  Exception for libcurl errors.
 *
 *  @since  0.1.0
 */
class CURLException : public exception
{
public:
    /*!
     *  @brief  Constructor with error code and message.
     *
     *  @since  0.1.0
     */
    explicit CURLException(const CURLcode &error, string message);

    /*!
     *  @brief Constructor with error code, message and error buffer.
     *
     *  @since  0.1.0
     */
    explicit CURLException(const CURLcode &error, string message,
                           string error_buffer);

    /*!
     *  @brief  The error code returned by libcurl.
     *
     *  @since  0.1.0
     */
    const CURLcode error_code;

    /*!
     *  @brief  Returns the error code, message and error buffer.
     *
     *  @since  0.1.0
     */
    [[nodiscard]]
    const char *what() const noexcept override;

private:
    const string _message;
    const string _error_buffer;
};

} // namespace mastodonpp

#endif  // MASTODONPP_EXCEPTIONS_HPP