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\u003eThe provided content is a documentation page for the \u003ccode\u003eStatus\u003c/code\u003e class in the Google Cloud C++ library, specifically version 2.28.0, 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 indicates success with an "OK" status, which is characterized by \u003ccode\u003eStatusCode::kOk\u003c/code\u003e, an empty message, an empty error info, and \u003ccode\u003eok()\u003c/code\u003e returning \u003ccode\u003etrue\u003c/code\u003e, and it is a regular value type that can be copied, moved, compared, and streamed.\u003c/p\u003e\n"],["\u003cp\u003eNon-OK \u003ccode\u003eStatus\u003c/code\u003e objects represent errors, and users can access error information through member functions or by streaming the \u003ccode\u003eStatus\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eThe page provides links to different versions of the documentation, ranging from the latest release candidate 2.37.0-rc down to version 2.10.1, all of which correspond to the \u003ccode\u003eStatus\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eStatus\u003c/code\u003e object can be constructed in a number of ways, namely default construction that defaults to \u003ccode\u003eStatusCode::kOk\u003c/code\u003e, Copy construction and assignment, Move construction and assignment, or a custom construction that takes a \u003ccode\u003eStatusCode\u003c/code\u003e, a message, and \u003ccode\u003eErrorInfo\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Class Status (2.28.0)\n\nVersion 2.28.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.28.0/classgoogle_1_1cloud_1_1Status#classgoogle_1_1cloud_1_1Status_1ac18337d2ceb00ca007725d21f2c63f9f)`==`[`StatusCode::kOk`](/cpp/docs/reference/common/2.28.0/namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847#namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847ae69fa9a656f76dd8a4d89f21992b2d3a) and `.`[`ok()`](/cpp/docs/reference/common/2.28.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.28.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.28.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.28.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.28.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.28.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.28.0/classgoogle_1_1cloud_1_1Status#classgoogle_1_1cloud_1_1Status_1ac18337d2ceb00ca007725d21f2c63f9f) is [`StatusCode::kOk`](/cpp/docs/reference/common/2.28.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.28.0/classgoogle_1_1cloud_1_1Status#classgoogle_1_1cloud_1_1Status_1ac18337d2ceb00ca007725d21f2c63f9f) is [`StatusCode::kOk`](/cpp/docs/reference/common/2.28.0/namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847#namespacegoogle_1_1cloud_1a90e17f75452470f0f3ee1a06ffe58847ae69fa9a656f76dd8a4d89f21992b2d3a)."]]