Class ErrorInfo (2.46.0-rc)

Describes the cause of the error with structured details.

Constructors

ErrorInfo()

Default constructor.

Post-condition: thereason(),domain(), andmetadata() fields are empty.

ErrorInfo(std::string, std::string, std::unordered_map< std::string, std::string >)

Constructor.

Parameters
NameDescription
reasonstd::string

initializes thereason() value.

domainstd::string

initializes thedomain() value.

metadatastd::unordered_map< std::string, std::string >

initializes themetadata() value.

Functions

reason() const

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.

Returns
TypeDescription
std::string const &

domain() const

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 isgcloud-cpp.

Returns
TypeDescription
std::string const &

metadata() const

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"}.

Returns
TypeDescription
std::unordered_map< std::string, std::string > const &

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-17 UTC.