This library never throws exceptions to signal error. In general, the library returns a StatusOr if an error is possible. Some functions return objects that are not wrapped in a StatusOr<T> but will themselves return a StatusOr<T> to signal an error. For example, wrappers for asynchronous operations return future<StatusOr<T>>.
Applications should check if the StatusOr<T> contains a value before using it, much like how you might check that a pointer is not null before dereferencing it. Indeed, a StatusOr<T> 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.
You can check that a StatusOr<T> 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->(). As with all smart pointers, callers must first check that the StatusOr<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 a RuntimeStatusError if there is no value.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["\u003cp\u003eThis page documents error handling in the Bigtable C++ library, focusing on how errors are managed without the use of exceptions.\u003c/p\u003e\n"],["\u003cp\u003eThe library uses \u003ccode\u003eStatusOr<T>\u003c/code\u003e to indicate potential errors, similar to a smart pointer, and applications must check if it contains a value before accessing it.\u003c/p\u003e\n"],["\u003cp\u003eYou can determine whether \u003ccode\u003eStatusOr<T>\u003c/code\u003e contains a value using the \u003ccode\u003e.ok()\u003c/code\u003e method or \u003ccode\u003eoperator bool()\u003c/code\u003e, and retrieve the \u003ccode\u003eStatus\u003c/code\u003e object via \u003ccode\u003e.status()\u003c/code\u003e if no value is present.\u003c/p\u003e\n"],["\u003cp\u003eAccess the contained value in \u003ccode\u003eStatusOr<T>\u003c/code\u003e by dereferencing with \u003ccode\u003eoperator*()\u003c/code\u003e or \u003ccode\u003eoperator->()\u003c/code\u003e, or by using \u003ccode\u003e.value()\u003c/code\u003e, which throws \u003ccode\u003eRuntimeStatusError\u003c/code\u003e if there's no value (or terminates if exceptions are disabled).\u003c/p\u003e\n"],["\u003cp\u003eThe page includes a example of how to use \u003ccode\u003eStatusOr<T>\u003c/code\u003e in a read row operation, and contains references to the documentation of \u003ccode\u003egoogle::cloud::StatusOr\u003c/code\u003e, \u003ccode\u003egoogle::cloud::Status\u003c/code\u003e and \u003ccode\u003egoogle::cloud::future\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["Version 2.34.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."]]