Google Cloud C++ Client 2.10.1
C++ Client Library for Google Cloud Platform
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
google::cloud::ErrorInfo Class Reference

Describes the cause of the error with structured details. More...

#include <google/cloud/status.h>

Public Member Functions

 ErrorInfo ()=default
 Default constructor. More...
 
 ErrorInfo (std::string reason, std::string domain, std::unordered_map< std::string, std::string > metadata)
 Constructor. More...
 
std::string const & reason () const
 The reason of the error. More...
 
std::string const & domain () const
 The logical grouping to which the "reason" belongs. More...
 
std::unordered_map< std::string, std::string > const & metadata () const
 Additional structured details about this error. More...
 

Friends

bool operator== (ErrorInfo const &, ErrorInfo const &)
 
bool operator!= (ErrorInfo const &, ErrorInfo const &)
 

Detailed Description

Describes the cause of the error with structured details.

See also
https://cloud.google.com/apis/design/errors#error_info

Constructor & Destructor Documentation

◆ ErrorInfo() [1/2]

google::cloud::ErrorInfo::ErrorInfo ( )
default

Default constructor.

Post-condition: the reason(), domain(), and metadata() fields are empty.

◆ ErrorInfo() [2/2]

google::cloud::ErrorInfo::ErrorInfo ( std::string  reason,
std::string  domain,
std::unordered_map< std::string, std::string >  metadata 
)
inlineexplicit

Constructor.

Parameters
reasoninitializes the reason() value.
domaininitializes the domain() value.
metadatainitializes the metadata() value.

Member Function Documentation

◆ domain()

std::string const & google::cloud::ErrorInfo::domain ( ) const
inline

The logical grouping to which the "reason" belongs.

The error domain is typically the registered service name of the tool or product that generates the error. Example: "pubsub.googleapis.com". If the error is generated by some common infrastructure, the error domain must be a globally unique value that identifies the infrastructure. For Google API infrastructure, the error domain is "googleapis.com".

For errors generated by the C++ client libraries the domain is gcloud-cpp.

◆ metadata()

std::unordered_map< std::string, std::string > const & google::cloud::ErrorInfo::metadata ( ) const
inline

Additional structured details about this error.

Keys should match the regular expression [a-zA-Z0-9-_] and be limited to 64 characters in length.

When identifying the current value of an exceeded limit, the units should be contained in the key, not the value. For example, if the client exceeds the number of instances that can be created in a single (batch) request return {"instanceLimitPerRequest": "100"} rather than {"instanceLimit": "100/request"}.

◆ reason()

std::string const & google::cloud::ErrorInfo::reason ( ) const
inline

The reason of the error.

This is a constant value that identifies the proximate cause of the error. Error reasons are unique within a particular domain of errors. This should be at most 63 characters and match a regular expression of [A-Z][A-Z0-9_]+[A-Z0-9], which represents UPPER_SNAKE_CASE.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( ErrorInfo const &  ,
ErrorInfo const &   
)
friend

◆ operator==

bool operator== ( ErrorInfo const &  ,
ErrorInfo const &   
)
friend