Google Cloud C++ Client
2.2.1
C++ Client Library for Google Cloud Platform
terminate_handler.h
Go to the documentation of this file.
1
// Copyright 2018 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#
ifndef
GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_TERMINATE_HANDLER_H
16
#
define
GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_TERMINATE_HANDLER_H
17
18
#
include
"google/cloud/version.h"
19
#
include
<
functional
>
20
21
namespace
google
{
22
namespace
cloud
{
23
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
24
//@{
25
/**
26
* @name Control behaviour on unrecoverable errors.
27
*
28
* The following APIs are google::cloud counterpart for
29
* std::{set,get}_terminate functions. If exceptions are not enabled via
30
* GOOGLE_CLOUD_CPP_HAVE_EXCEPTIONS, calling any function from throw_delegate.h
31
* will result in calling the handler installed via this API. By default,
32
* a call to std::abort() is used.
33
*/
34
35
/**
36
* Terminate handler.
37
*
38
* It should handle the error, whose description are given in *msg* and should
39
* never return.
40
*/
41
using
TerminateHandler = std::function<
void
(
char
const
* msg)>;
42
43
/**
44
* Install terminate handler and get the old one atomically.
45
*
46
* @param f the handler. It should never return, behaviour is undefined
47
* otherwise.
48
*
49
* @return Previously set handler.
50
*/
51
TerminateHandler
SetTerminateHandler
(TerminateHandler f);
52
53
/**
54
* Get the currently installed handler.
55
*
56
* @return The currently installed handler.
57
*/
58
TerminateHandler
GetTerminateHandler
();
59
60
/**
61
* Invoke the currently installed handler.
62
*
63
* @param msg Details about the error.
64
*
65
* This function should never return.
66
*
67
*/
68
[[noreturn]]
void
Terminate
(
char
const
* msg);
69
70
//@}
71
72
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
73
}
// namespace cloud
74
}
// namespace google
75
76
#
endif
// GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_TERMINATE_HANDLER_H
Generated on Thu Sep 15 2022 21:58:47 for Google Cloud C++ Client by
1.9.1