In some rare cases, the client libraries may need to terminate the application because it encounters an unrecoverable error. For example:
If the application calls StatusOr<T>::value(), and the library was compiled with exceptions disabled, and the StatusOr<T> contains an error, then the function throws an exception to report the error as the function cannot return a valid value. Applications that disable exceptions should query the StatusOr<T> status (using .ok() or .status()) and avoid calling .value() if the StatusOr<T> is holding an error.
If the application calls future<T>::get(), the library was compiled with exceptions disabled, and (somehow) the future is satisfied with an exception. Note that the library APIs typically return future<StatusOr<T>> to avoid this problem, but the application may have created future<T> and promise<T> pairs in their own code.
In these cases there is no mechanism to return the error. The library cannot continue working correctly and must terminate the program. The application may want to intercept these errors, before the application crashes, and log or otherwise capture additional information to help with debugging or troubleshooting. The functions in this module can be used to do so.
By their nature, there is no mechanism to "handle" and "recover" from unrecoverable errors. All the application can do is log additional information before the program terminates.
Note that the libraries do not use functions that can trigger unrecoverable errors (if they do we consider that a library bug).
The default behavior in the client library is to call std::abort() when an unrecoverable error occurs.
[[["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-03-05 UTC."],[[["The client libraries may terminate the application upon encountering unrecoverable errors, such as when `StatusOr\u003cT\u003e::value()` is called with an error and exceptions are disabled, or when a `future\u003cT\u003e::get()` call results in an exception."],["These unrecoverable errors are situations where the library cannot continue operating correctly and must terminate the program, with no ability to recover or handle the error in the traditional sense."],["The provided functions (`SetTerminateHandler`, `GetTerminateHandler`, `Terminate`) and the `TerminateHandler` type can be used to intercept these errors before the application crashes, allowing for the logging of additional information for debugging."],["The default behavior for unrecoverable errors is to call `std::abort()`, and the library avoids using functions that could trigger these types of errors."],["The content provides a comprehensive list of older versions, ranging from version 2.37.0-rc to 2.10.1, that can be used as a reference point to help prevent future errors."]]],[]]