A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
Loading...
Searching...
No Matches
status.h File Reference

A11's error type and its protocol/JSON bridges. More...

#include <cstdint>
#include <string>
#include <string_view>
#include <absl/status/status.h>
#include <absl/status/statusor.h>
#include <nlohmann/json_fwd.hpp>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  a11
 

Functions

absl::StatusCode a11::StatusCodeFromHttp (int http_code)
 Maps an HTTP status code to a canonical status code.
 
int a11::StatusCodeToHttp (absl::StatusCode code)
 Maps a canonical status code to its HTTP status code.
 
absl::StatusCode a11::StatusCodeFromWebSocket (std::uint16_t close_code)
 Maps a WebSocket close code to a canonical status code.
 
std::uint16_t a11::StatusCodeToWebSocket (absl::StatusCode code)
 Maps a canonical status code to its WebSocket close code.
 
absl::Status a11::MakeStatus (absl::StatusCode code, std::string message, nlohmann::json details)
 Builds a status carrying an A11 structured-details payload.
 
nlohmann::json a11::StatusDetails (const absl::Status &status)
 Extracts the structured-details payload from a status.
 
absl::StatusOr< nlohmann::json > a11::StatusToJson (const absl::Status &status)
 Serializes a status (code, message, details) to JSON.
 
absl::StatusOr< absl::Status > a11::StatusFromJson (const nlohmann::json &value)
 Reconstructs a status from its JSON representation.
 

Variables

constexpr std::string_view a11::kStatusDetailsPayloadUrl
 Type URL identifying A11's status-details payload.
 

Detailed Description

A11's error type and its protocol/JSON bridges.

A11 uses Abseil's absl::Status (and the canonical absl::StatusCode enumeration) as its error carrier rather than defining a bespoke type. This header adds the pieces A11 layers on top: mappings between status codes and the HTTP and WebSocket close codes that form part of the public wire contract, and helpers that carry A11's optional structured "details" payload through JSON (and, via JSON, MessagePack) round-trips.