Represents success or an error with info about the error.
This class is typically used to indicate whether or not a function or other operation completed successfully. Success is indicated by an "OK" status. OK statuses will have.code()==StatusCode::kOkand.ok()== true, with all other properties having empty values. All OK statuses are equal. Any non-OKStatusis considered an error. Users can inspect the error using the member functions, or they can simply stream theStatusobject, and it will print itself in some human readable way (the streamed format may change over time and you shouldnotdepend on the specific format of a streamedStatusobject remaining unchanged).
This is a regular value type that can be copied, moved, compared for equality, and streamed.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis document outlines the \u003ccode\u003eStatus\u003c/code\u003e class in C++, which is used to represent the outcome of an operation, indicating either success or an error.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eStatus\u003c/code\u003e class has a default constructor that initializes it to \u003ccode\u003eStatusCode::kOk\u003c/code\u003e, representing a successful operation, and any non-OK status is considered an error.\u003c/p\u003e\n"],["\u003cp\u003eThe document provides a list of different versions, with version 2.37.0-rc being the latest, including the ability to copy, move, compare for equality, and stream \u003ccode\u003eStatus\u003c/code\u003e objects.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eStatus\u003c/code\u003e class has functions to verify the status, such as \u003ccode\u003eok()\u003c/code\u003e, \u003ccode\u003ecode()\u003c/code\u003e, \u003ccode\u003emessage()\u003c/code\u003e, and \u003ccode\u003eerror_info()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eStatus\u003c/code\u003e objects have constructors to be initialized with status codes, messages, and error information, and they can be copied or moved as needed.\u003c/p\u003e\n"]]],[],null,["# Class Status (2.34.0)\n\nVersion 2.34.0keyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1Status)\n- [2.41.0](/cpp/docs/reference/common/2.41.0/classgoogle_1_1cloud_1_1Status)\n- [2.40.0](/cpp/docs/reference/common/2.40.0/classgoogle_1_1cloud_1_1Status)\n- [2.39.0](/cpp/docs/reference/common/2.39.0/classgoogle_1_1cloud_1_1Status)\n- [2.38.0](/cpp/docs/reference/common/2.38.0/classgoogle_1_1cloud_1_1Status)\n- [2.37.0](/cpp/docs/reference/common/2.37.0/classgoogle_1_1cloud_1_1Status)\n- [2.36.0](/cpp/docs/reference/common/2.36.0/classgoogle_1_1cloud_1_1Status)\n- [2.35.0](/cpp/docs/reference/common/2.35.0/classgoogle_1_1cloud_1_1Status)\n- [2.34.0](/cpp/docs/reference/common/2.34.0/classgoogle_1_1cloud_1_1Status)\n- [2.33.0](/cpp/docs/reference/common/2.33.0/classgoogle_1_1cloud_1_1Status)\n- [2.32.0](/cpp/docs/reference/common/2.32.0/classgoogle_1_1cloud_1_1Status)\n- [2.31.0](/cpp/docs/reference/common/2.31.0/classgoogle_1_1cloud_1_1Status)\n- [2.30.0](/cpp/docs/reference/common/2.30.0/classgoogle_1_1cloud_1_1Status)\n- [2.29.0](/cpp/docs/reference/common/2.29.0/classgoogle_1_1cloud_1_1Status)\n- [2.28.0](/cpp/docs/reference/common/2.28.0/classgoogle_1_1cloud_1_1Status)\n- [2.27.0](/cpp/docs/reference/common/2.27.0/classgoogle_1_1cloud_1_1Status)\n- [2.26.0](/cpp/docs/reference/common/2.26.0/classgoogle_1_1cloud_1_1Status)\n- [2.25.1](/cpp/docs/reference/common/2.25.1/classgoogle_1_1cloud_1_1Status)\n- [2.24.0](/cpp/docs/reference/common/2.24.0/classgoogle_1_1cloud_1_1Status)\n- [2.23.0](/cpp/docs/reference/common/2.23.0/classgoogle_1_1cloud_1_1Status)\n- [2.22.1](/cpp/docs/reference/common/2.22.1/classgoogle_1_1cloud_1_1Status)\n- [2.21.0](/cpp/docs/reference/common/2.21.0/classgoogle_1_1cloud_1_1Status)\n- [2.20.0](/cpp/docs/reference/common/2.20.0/classgoogle_1_1cloud_1_1Status)\n- [2.19.0](/cpp/docs/reference/common/2.19.0/classgoogle_1_1cloud_1_1Status)\n- [2.18.0](/cpp/docs/reference/common/2.18.0/classgoogle_1_1cloud_1_1Status)\n- [2.17.0](/cpp/docs/reference/common/2.17.0/classgoogle_1_1cloud_1_1Status)\n- [2.16.0](/cpp/docs/reference/common/2.16.0/classgoogle_1_1cloud_1_1Status)\n- [2.15.1](/cpp/docs/reference/common/2.15.1/classgoogle_1_1cloud_1_1Status)\n- [2.14.0](/cpp/docs/reference/common/2.14.0/classgoogle_1_1cloud_1_1Status)\n- [2.13.0](/cpp/docs/reference/common/2.13.0/classgoogle_1_1cloud_1_1Status)\n- [2.12.0](/cpp/docs/reference/common/2.12.0/classgoogle_1_1cloud_1_1Status)\n- [2.11.0](/cpp/docs/reference/common/2.11.0/classgoogle_1_1cloud_1_1Status)\n- [2.10.1](/cpp/docs/reference/common/2.10.1/classgoogle_1_1cloud_1_1Status) \nRepresents success or an error with info about the error. \nThis class is typically used to indicate whether or not a function or other operation completed successfully. Success is indicated by an \"OK\" status. OK statuses will have `.`[`code()`](/cpp/docs/reference/common/2.34.0/classgoogle_1_1cloud_1_1Status#classgoogle_1_1cloud_1_1Status_1ac18337d2ceb00ca007725d21f2c63f9f)`==`[`StatusCode::kOk`](/cpp/docs/reference/common/2.34.0/namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847#namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847ae69fa9a656f76dd8a4d89f21992b2d3a) and `.`[`ok()`](/cpp/docs/reference/common/2.34.0/classgoogle_1_1cloud_1_1Status#classgoogle_1_1cloud_1_1Status_1a18952043ffe5a4f74911c8146e8bb504)`== true`, with all other properties having empty values. All OK statuses are equal. Any non-OK [`Status`](/cpp/docs/reference/common/2.34.0/classgoogle_1_1cloud_1_1Status) is considered an error. Users can inspect the error using the member functions, or they can simply stream the [`Status`](/cpp/docs/reference/common/2.34.0/classgoogle_1_1cloud_1_1Status) object, and it will print itself in some human readable way (the streamed format may change over time and you should *not* depend on the specific format of a streamed [`Status`](/cpp/docs/reference/common/2.34.0/classgoogle_1_1cloud_1_1Status) object remaining unchanged).\n\nThis is a regular value type that can be copied, moved, compared for equality, and streamed.\n\nConstructors\n------------\n\n### Status(Status const \\&)\n\nCopy construction and assignment.\n\n### Status(Status \\&\\&)\n\nMove construction and assignment.\n\n### Status()\n\nDefault constructor, initializes to [`StatusCode::kOk`](/cpp/docs/reference/common/2.34.0/namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847#namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847ae69fa9a656f76dd8a4d89f21992b2d3a).\n\n### Status(StatusCode, std::string, ErrorInfo)\n\nConstruct from a status code, message and (optional) error info.\n\nOperators\n---------\n\n### operator=(Status const \\&)\n\nCopy construction and assignment.\n\n### operator=(Status \\&\\&)\n\nMove construction and assignment.\n\nFunctions\n---------\n\n### ok() const\n\nReturns true if the status code is [`StatusCode::kOk`](/cpp/docs/reference/common/2.34.0/namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847#namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847ae69fa9a656f76dd8a4d89f21992b2d3a).\n\n### code() const\n\nReturns the status code.\n\n### message() const\n\nReturns the message associated with the status. \nThis is always empty if [`code()`](/cpp/docs/reference/common/2.34.0/classgoogle_1_1cloud_1_1Status#classgoogle_1_1cloud_1_1Status_1ac18337d2ceb00ca007725d21f2c63f9f) is [`StatusCode::kOk`](/cpp/docs/reference/common/2.34.0/namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847#namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847ae69fa9a656f76dd8a4d89f21992b2d3a).\n\n### error_info() const\n\nReturns the additional error info associated with the status. \nThis is always a default-constructed error info if [`code()`](/cpp/docs/reference/common/2.34.0/classgoogle_1_1cloud_1_1Status#classgoogle_1_1cloud_1_1Status_1ac18337d2ceb00ca007725d21f2c63f9f) is [`StatusCode::kOk`](/cpp/docs/reference/common/2.34.0/namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847#namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847ae69fa9a656f76dd8a4d89f21992b2d3a)."]]