Boost C++ Libraries

PrevUpHomeNext

Function make_error_response

boost::taar::jsonrpc::make_error_response — Build a JSON-RPC 2.0 error response envelope.

Synopsis

// In header: <boost/taar/jsonrpc/response.hpp>


boost::json::value 
make_error_response(boost::json::value id, int code, std::string message, 
                    std::optional< boost::json::value > data = std::nullopt);

Description

Produces the spec's error response shape:

{ "jsonrpc": "2.0", "id": <id>,
  "error": { "code": <code>, "message": <message>[, "data": <data>] } }

Parameters:

id

The id from the originating request, or null if the request could not be parsed enough to recover one (per the spec, errors emitted before id extraction use null).

code

The numeric error code. Use the error enum's -32700..-32603 for protocol-level failures; the -32000..-32099 range is reserved for application server errors.

message

Short human-readable description.

data

Optional additional context. Omitted from the envelope when empty.


PrevUpHomeNext