1#ifndef SOURCEMETA_CORE_HTTP_ERROR_H_
2#define SOURCEMETA_CORE_HTTP_ERROR_H_
4#ifndef SOURCEMETA_CORE_HTTP_EXPORT
5#include <sourcemeta/core/http_export.h>
8#include <sourcemeta/core/http_method.h>
9#include <sourcemeta/core/http_status.h>
16namespace sourcemeta::core {
22#pragma warning(disable : 4251 4275)
39class SOURCEMETA_CORE_HTTP_EXPORT
HTTPError :
public std::runtime_error {
43 const std::string &message)
44 : std::runtime_error{message}, method_{
method}, url_{std::move(
url)} {}
52 [[nodiscard]]
auto url() const noexcept -> const std::
string & {
86 return {.code = this->code_, .phrase = this->phrase_, .wire = this->wire_};
96#pragma warning(default : 4251 4275)
auto method() const noexcept -> HTTPMethod
Get the request method that triggered the failure.
Definition http_error.h:47
auto status() const noexcept -> HTTPStatus
Definition http_error.h:85
auto url() const noexcept -> const std::string &
Get the request URL that triggered the failure.
Definition http_error.h:52
HTTPError(const HTTPMethod method, std::string url, const std::string &message)
Construct an error from the request method, URL, and a message.
Definition http_error.h:42
HTTPStatusError(const HTTPMethod method, std::string url, const HTTPStatus &status)
Definition http_error.h:78
HTTPMethod
Definition http_method.h:12