#pragma once /* * Copyright (C) 2024 Dominik Meyer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * @brief The main namespace of this library for Redmine related datatypes, classes, and functions * */ #include #include namespace Redmine { /** * @brief namespace for all exceptions * */ namespace Exception { /** * @brief exception returning all errors generated by an redmine api request * */ class Api : public std::exception { private: /// the overall exception msg std::string msg_; /// vector for storing all api errors of a request std::vector errors_; public: /** * @brief constructor for just creating an exception * * @param message */ explicit Api(const char* message) : msg_(message) {} /** * @brief Constructor for creating an exception and add error messages * * @param message * @param errors */ Api(const char* message, const std::vector &errors) : msg_(message), errors_(errors) {} /** * @brief add error to an existing exception * * @param error */ void addError(const std::string &error) {errors_.push_back(error);} /** * @brief Return all errors of an exception * * @return std::vector */ std::vector getErrors() const {return errors_;} /** * @brief return the what of an exception * * @return const char* */ virtual const char* what() const noexcept { return msg_.c_str(); } virtual ~Api() noexcept {} }; // class Api }; // namespace Exception }; // namespace Redmine