userver: ugrpc::ErrorInfo Struct Reference
Loading...
Searching...
No Matches
ugrpc::ErrorInfo Struct Reference

#include <userver/ugrpc/rich_status.hpp>

Detailed Description

Provides structured error information about the cause of an error.

See also
https:///google.aip.dev/193
https:///github.com/googleapis/googleapis/blob/master/google/rpc/error_details.proto
ugrpc::RichStatus

Use this detail to provide a machine-readable error reason, domain, and additional metadata. This is useful for error handling logic on the client side.

Any request-specific information which contributes to the Status.message or LocalizedMessage.message messages must be represented within metadata. This practice is critical so that machine actors do not need to parse error messages to extract information.

Example usage:

grpc::StatusCode::UNAUTHENTICATED,
"Authentication failed",
"INVALID_TOKEN",
"auth.example.com",
{{"token_type", "bearer"}, {"error", "expired"}},
},
};

Definition at line 107 of file rich_status.hpp.

Public Member Functions

google::rpc::ErrorInfo ToGoogleErrorDetail () const &
 
google::rpc::ErrorInfo ToGoogleErrorDetail () &&
 

Static Public Member Functions

static std::optional< ErrorInfoTryUnpack (const google::protobuf::Any &any)
 

Public Attributes

std::string reason
 The reason of the error (e.g., "INVALID_TOKEN", "SERVICE_DISABLED").
 
std::string domain
 The logical grouping to which the error belongs (e.g., "auth.example.com").
 
std::unordered_map< std::string, std::string > metadata
 Additional structured details about the error.
 

Member Data Documentation

◆ domain

std::string ugrpc::ErrorInfo::domain

The logical grouping to which the error belongs (e.g., "auth.example.com").

Definition at line 117 of file rich_status.hpp.

◆ metadata

std::unordered_map<std::string, std::string> ugrpc::ErrorInfo::metadata

Additional structured details about the error.

Definition at line 120 of file rich_status.hpp.

◆ reason

std::string ugrpc::ErrorInfo::reason

The reason of the error (e.g., "INVALID_TOKEN", "SERVICE_DISABLED").

The reason field is a short snake_case description of the cause of the error. Error reasons are unique within a particular domain of errors. The reason must be at most 63 characters and match a regular expression of [A-Z][A-Z0-9_]+[A-Z0-9]. (This is UPPER_SNAKE_CASE, without leading or trailing underscores, and without leading digits.)

Definition at line 114 of file rich_status.hpp.


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