Google Cloud C++ Client 2.10.1
C++ Client Library for Google Cloud Platform
Loading...
Searching...
No Matches
Typedefs | Functions
Intercepting Unrecoverable Errors

Helper types and functions to report unrecoverable errors. More...

Typedefs

using google::cloud::TerminateHandler = std::function< void(char const *msg)>
 Terminate handler. More...
 

Functions

TerminateHandler google::cloud::SetTerminateHandler (TerminateHandler f)
 Install terminate handler and get the old one atomically. More...
 
TerminateHandler google::cloud::GetTerminateHandler ()
 Get the currently installed handler. More...
 
void google::cloud::Terminate (char const *msg)
 Invoke the currently installed handler. More...
 

Detailed Description

Helper types and functions to report unrecoverable errors.

In some rare cases, the client libraries may need to terminate the application because it encounters an unrecoverable error. For example:

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.

Typedef Documentation

◆ TerminateHandler

using google::cloud::TerminateHandler = typedef std::function<void(char const* msg)>

Terminate handler.

It should handle the error, whose description are given in msg and should never return.

Function Documentation

◆ GetTerminateHandler()

TerminateHandler google::cloud::GetTerminateHandler ( )

Get the currently installed handler.

Returns
The currently installed handler.

◆ SetTerminateHandler()

TerminateHandler google::cloud::SetTerminateHandler ( TerminateHandler  f)

Install terminate handler and get the old one atomically.

Parameters
fthe handler. It should never return, behaviour is undefined otherwise.
Returns
Previously set handler.

◆ Terminate()

void google::cloud::Terminate ( char const *  msg)

Invoke the currently installed handler.

Parameters
msgDetails about the error.

This function should never return.