cpp Rest API master
C++ library for REST API access with Qt, Curl and cpp-httplib backends
 
Loading...
Searching...
No Matches
cpp_restapi::HttpError Struct Reference

Represents an HTTP or network-level error. More...

#include <http_error.hpp>

Public Attributes

int statusCode
 HTTP status code (e.g. 404, 500). 0 means a network-level failure — no HTTP response was received.
 
std::string body
 Raw response body (often contains error details for 4xx/5xx responses)
 
std::string message
 Human-readable error description.
 

Detailed Description

Represents an HTTP or network-level error.

Returned by IConnection::fetch() and IConnection::fetchResponse() when a request cannot be completed successfully.

auto result = connection.fetch("users/foo");
if (!result)
{
if (result.error().statusCode == 0)
// network-level failure (timeout, DNS, etc.)
else if (result.error().statusCode == 404)
// resource not found
else
// other HTTP error
}

Member Data Documentation

◆ body

std::string cpp_restapi::HttpError::body

Raw response body (often contains error details for 4xx/5xx responses)

◆ message

std::string cpp_restapi::HttpError::message

Human-readable error description.

◆ statusCode

int cpp_restapi::HttpError::statusCode

HTTP status code (e.g. 404, 500). 0 means a network-level failure — no HTTP response was received.


The documentation for this struct was generated from the following file: