| 1234567891011121314151617181920 |
- #pragma once
- #include <stdexcept>
- #include <string>
- #include <nlohmann/json.hpp>
- namespace svapi {
- enum class ErrCode { BadRequest, Unauthorized, Forbidden, NotFound, Unprocessable, Unavailable, Internal };
- int httpStatus(ErrCode code);
- nlohmann::json errorBody(const std::string& code, const std::string& message);
- struct ApiError : std::runtime_error {
- ErrCode code;
- std::string slug;
- ApiError(ErrCode c, std::string slug_, const std::string& msg)
- : std::runtime_error(msg), code(c), slug(std::move(slug_)) {}
- };
- } // namespace svapi
|