This library never throws exceptions to signal error. In general, the library returns aStatusOrif an error is possible. Some functions return objects that are not wrapped in aStatusOr<T>but will themselves return aStatusOr<T>to signal an error. For example, wrappers for asynchronous operations returnfuture<StatusOr<T>>.
Applications should check if theStatusOr<T>contains a value before using it, much like how you might check that a pointer is not null before dereferencing it. Indeed, aStatusOr<T>object can be used like a smart-pointer toT, with the main difference being that when it does not hold aTit will instead hold aStatusobject with extra information about the error.
You can check that aStatusOr<T>contains a value by calling the.ok()method, or by usingoperator bool()(like with other smart pointers). If there is no value, you can access the containedStatusobject using the.status()member. If there is a value, you may access it by dereferencing withoperator*()oroperator->(). As with all smart pointers, callers must first check that theStatusOr<T>contains a value before dereferencing and accessing the contained value. Alternatively, callers may instead use the.value()member function which is defined to throw aRuntimeStatusErrorif there is no value.
[[["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."],[],[],null,["Version 2.41.0keyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/bigtable/latest/bigtable-error-handling)\n- [2.41.0](/cpp/docs/reference/bigtable/2.41.0/bigtable-error-handling)\n- [2.40.0](/cpp/docs/reference/bigtable/2.40.0/bigtable-error-handling)\n- [2.39.0](/cpp/docs/reference/bigtable/2.39.0/bigtable-error-handling)\n- [2.38.0](/cpp/docs/reference/bigtable/2.38.0/bigtable-error-handling)\n- [2.37.0](/cpp/docs/reference/bigtable/2.37.0/bigtable-error-handling)\n- [2.36.0](/cpp/docs/reference/bigtable/2.36.0/bigtable-error-handling)\n- [2.35.0](/cpp/docs/reference/bigtable/2.35.0/bigtable-error-handling)\n- [2.34.0](/cpp/docs/reference/bigtable/2.34.0/bigtable-error-handling)\n- [2.33.0](/cpp/docs/reference/bigtable/2.33.0/bigtable-error-handling)\n- [2.32.0](/cpp/docs/reference/bigtable/2.32.0/bigtable-error-handling)\n- [2.31.0](/cpp/docs/reference/bigtable/2.31.0/bigtable-error-handling)\n- [2.30.0](/cpp/docs/reference/bigtable/2.30.0/bigtable-error-handling)\n- [2.29.0](/cpp/docs/reference/bigtable/2.29.0/bigtable-error-handling)\n- [2.28.0](/cpp/docs/reference/bigtable/2.28.0/bigtable-error-handling)\n- [2.27.0](/cpp/docs/reference/bigtable/2.27.0/bigtable-error-handling)\n- [2.26.0](/cpp/docs/reference/bigtable/2.26.0/bigtable-error-handling)\n- [2.25.1](/cpp/docs/reference/bigtable/2.25.1/bigtable-error-handling)\n- [2.24.0](/cpp/docs/reference/bigtable/2.24.0/bigtable-error-handling)\n- [2.23.0](/cpp/docs/reference/bigtable/2.23.0/bigtable-error-handling)\n- [2.22.1](/cpp/docs/reference/bigtable/2.22.1/bigtable-error-handling)\n- [2.21.0](/cpp/docs/reference/bigtable/2.21.0/bigtable-error-handling)\n- [2.20.0](/cpp/docs/reference/bigtable/2.20.0/bigtable-error-handling)\n- [2.19.0](/cpp/docs/reference/bigtable/2.19.0/bigtable-error-handling)\n- [2.18.0](/cpp/docs/reference/bigtable/2.18.0/bigtable-error-handling)\n- [2.17.0](/cpp/docs/reference/bigtable/2.17.0/bigtable-error-handling)\n- [2.16.0](/cpp/docs/reference/bigtable/2.16.0/bigtable-error-handling)\n- [2.15.1](/cpp/docs/reference/bigtable/2.15.1/bigtable-error-handling)\n- [2.14.0](/cpp/docs/reference/bigtable/2.14.0/bigtable-error-handling)\n- [2.13.0](/cpp/docs/reference/bigtable/2.13.0/bigtable-error-handling)\n- [2.12.0](/cpp/docs/reference/bigtable/2.12.0/bigtable-error-handling)\n- [2.11.0](/cpp/docs/reference/bigtable/2.11.0/bigtable-error-handling) \n\nError Handling\n==============\n\nThis library never throws exceptions to signal error. In general, the library returns a [StatusOr](https://cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1StatusOr.html) if an error is possible. Some functions return objects that are not wrapped in a `StatusOr\u003cT\u003e` but will themselves return a `StatusOr\u003cT\u003e` to signal an error. For example, wrappers for asynchronous operations return `future\u003cStatusOr\u003cT\u003e\u003e`.\n\nApplications should check if the `StatusOr\u003cT\u003e` contains a value before using it, much like how you might check that a pointer is not null before dereferencing it. Indeed, a `StatusOr\u003cT\u003e` object can be used like a smart-pointer to `T`, with the main difference being that when it does not hold a `T` it will instead hold a `Status` object with extra information about the error.\n\nYou can check that a `StatusOr\u003cT\u003e` contains a value by calling the `.ok()` method, or by using `operator bool()` (like with other smart pointers). If there is no value, you can access the contained `Status` object using the `.status()` member. If there is a value, you may access it by dereferencing with `operator*()` or `operator-\u003e()`. As with all smart pointers, callers must first check that the `StatusOr\u003cT\u003e` contains a value before dereferencing and accessing the contained value. Alternatively, callers may instead use the `.value()` member function which is defined to throw a [RuntimeStatusError](https://cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1RuntimeStatusError.html) if there is no value.\n| **Note:** If you're compiling with exceptions disabled, calling `.value()` on a `StatusOr\u003cT\u003e` that does not contain a value will terminate the program instead of throwing.\n\n###### Example\n\n namespace cbt = ::google::cloud::bigtable;\n using ::google::cloud::StatusOr;\n [](google::cloud::bigtable::Table table, std::string const& row_key) {\n StatusOr\u003cstd::pair\u003cbool, cbt::Row\u003e\u003e tuple = table.ReadRow(\n row_key, cbt::Filter::ColumnName(\"stats_summary\", \"os_build\"));\n if (!tuple) throw std::move(tuple).status();\n if (!tuple-\u003efirst) {\n std::cout \u003c\u003c \"Row \" \u003c\u003c row_key \u003c\u003c \" not found\\n\";\n return;\n }\n PrintRow(tuple-\u003esecond);\n }\n\n###### See Also\n\n[`google::cloud::StatusOr`](https://cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1StatusOr.html)\n\n###### See Also\n\n[`google::cloud::Status`](https://cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1Status.html) the class used to describe errors.\n\n###### See Also\n\n[`google::cloud::future`](https://cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1future.html) for more details on the type returned by asynchronous operations."]]