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/error.h>
9#include <sourcemeta/core/http_method.h>
10#include <sourcemeta/core/http_status.h>
18namespace sourcemeta::core {
20SOURCEMETA_CORE_ERROR_WARNINGS_PUSH
48 detail_{std::move(
detail)} {}
56 [[nodiscard]]
auto url() const noexcept -> const std::
string & {
61 [[nodiscard]]
auto detail() const noexcept -> std::string_view {
89 const std::chrono::milliseconds
timeout)
96 [[nodiscard]]
auto timeout() const noexcept -> std::chrono::milliseconds {
97 return this->timeout_;
101 std::chrono::milliseconds timeout_;
129 return {.code = this->code_, .phrase = this->phrase_, .wire = this->wire_};
140class SOURCEMETA_CORE_HTTP_EXPORT HTTPEntropyError :
public Error {
142 HTTPEntropyError() noexcept
143 :
Error{
"Could not draw a non-zero trace context identifier"} {}
146SOURCEMETA_CORE_ERROR_WARNINGS_POP
auto message() const noexcept -> StaticString
Definition error_base.h:78
Error(const StaticString message) noexcept
Construct the error given its message.
Definition error_base.h:84
auto method() const noexcept -> HTTPMethod
Get the request method that triggered the failure.
Definition http_error.h:51
auto status() const noexcept -> HTTPStatus
Definition http_error.h:128
auto timeout() const noexcept -> std::chrono::milliseconds
Definition http_error.h:96
auto url() const noexcept -> const std::string &
Get the request URL that triggered the failure.
Definition http_error.h:56
HTTPTimeoutError(const HTTPMethod method, std::string url, const std::chrono::milliseconds timeout)
Definition http_error.h:88
auto detail() const noexcept -> std::string_view
Get what the backend reported, empty when it reported nothing.
Definition http_error.h:61
HTTPError(const StaticString message, const HTTPMethod method, std::string url, std::string detail)
Definition http_error.h:45
HTTPError(const StaticString message, const HTTPMethod method, std::string url)
Construct an error from a message, the request method, and the URL.
Definition http_error.h:39
HTTPStatusError(const HTTPMethod method, std::string url, const HTTPStatus &status)
Definition http_error.h:121
HTTPMethod
Definition http_method.h:12
Definition text_static_string.h:20