Coverage Report

Created: 2026-09-14 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/abseil-cpp/absl/base/throw_delegate.cc
Line
Count
Source
1
// Copyright 2017 The Abseil Authors.
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
#include "absl/base/throw_delegate.h"
16
17
#include <cstdlib>
18
#include <functional>
19
#include <new>
20
#include <stdexcept>
21
#include <string>
22
23
#include "absl/base/config.h"
24
#include "absl/base/internal/raw_logging.h"
25
26
namespace absl {
27
ABSL_NAMESPACE_BEGIN
28
29
0
void ThrowStdLogicError(const std::string& what_arg) {
30
0
#ifdef ABSL_HAVE_EXCEPTIONS
31
0
  throw std::logic_error(what_arg);
32
#else
33
  ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
34
  std::abort();
35
#endif
36
0
}
37
0
void ThrowStdLogicError(const char* what_arg) {
38
0
#ifdef ABSL_HAVE_EXCEPTIONS
39
0
  throw std::logic_error(what_arg);
40
#else
41
  ABSL_RAW_LOG(FATAL, "%s", what_arg);
42
  std::abort();
43
#endif
44
0
}
45
0
void ThrowStdInvalidArgument(const std::string& what_arg) {
46
0
#ifdef ABSL_HAVE_EXCEPTIONS
47
0
  throw std::invalid_argument(what_arg);
48
#else
49
  ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
50
  std::abort();
51
#endif
52
0
}
53
0
void ThrowStdInvalidArgument(const char* what_arg) {
54
0
#ifdef ABSL_HAVE_EXCEPTIONS
55
0
  throw std::invalid_argument(what_arg);
56
#else
57
  ABSL_RAW_LOG(FATAL, "%s", what_arg);
58
  std::abort();
59
#endif
60
0
}
61
62
0
void ThrowStdDomainError(const std::string& what_arg) {
63
0
#ifdef ABSL_HAVE_EXCEPTIONS
64
0
  throw std::domain_error(what_arg);
65
#else
66
  ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
67
  std::abort();
68
#endif
69
0
}
70
0
void ThrowStdDomainError(const char* what_arg) {
71
0
#ifdef ABSL_HAVE_EXCEPTIONS
72
0
  throw std::domain_error(what_arg);
73
#else
74
  ABSL_RAW_LOG(FATAL, "%s", what_arg);
75
  std::abort();
76
#endif
77
0
}
78
79
0
void ThrowStdLengthError(const std::string& what_arg) {
80
0
#ifdef ABSL_HAVE_EXCEPTIONS
81
0
  throw std::length_error(what_arg);
82
#else
83
  ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
84
  std::abort();
85
#endif
86
0
}
87
0
void ThrowStdLengthError(const char* what_arg) {
88
0
#ifdef ABSL_HAVE_EXCEPTIONS
89
0
  throw std::length_error(what_arg);
90
#else
91
  ABSL_RAW_LOG(FATAL, "%s", what_arg);
92
  std::abort();
93
#endif
94
0
}
95
96
0
void ThrowStdOutOfRange(const std::string& what_arg) {
97
0
#ifdef ABSL_HAVE_EXCEPTIONS
98
0
  throw std::out_of_range(what_arg);
99
#else
100
  ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
101
  std::abort();
102
#endif
103
0
}
104
0
void ThrowStdOutOfRange(const char* what_arg) {
105
0
#ifdef ABSL_HAVE_EXCEPTIONS
106
0
  throw std::out_of_range(what_arg);
107
#else
108
  ABSL_RAW_LOG(FATAL, "%s", what_arg);
109
  std::abort();
110
#endif
111
0
}
112
113
0
void ThrowStdRuntimeError(const std::string& what_arg) {
114
0
#ifdef ABSL_HAVE_EXCEPTIONS
115
0
  throw std::runtime_error(what_arg);
116
#else
117
  ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
118
  std::abort();
119
#endif
120
0
}
121
0
void ThrowStdRuntimeError(const char* what_arg) {
122
0
#ifdef ABSL_HAVE_EXCEPTIONS
123
0
  throw std::runtime_error(what_arg);
124
#else
125
  ABSL_RAW_LOG(FATAL, "%s", what_arg);
126
  std::abort();
127
#endif
128
0
}
129
130
0
void ThrowStdRangeError(const std::string& what_arg) {
131
0
#ifdef ABSL_HAVE_EXCEPTIONS
132
0
  throw std::range_error(what_arg);
133
#else
134
  ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
135
  std::abort();
136
#endif
137
0
}
138
0
void ThrowStdRangeError(const char* what_arg) {
139
0
#ifdef ABSL_HAVE_EXCEPTIONS
140
0
  throw std::range_error(what_arg);
141
#else
142
  ABSL_RAW_LOG(FATAL, "%s", what_arg);
143
  std::abort();
144
#endif
145
0
}
146
147
0
void ThrowStdOverflowError(const std::string& what_arg) {
148
0
#ifdef ABSL_HAVE_EXCEPTIONS
149
0
  throw std::overflow_error(what_arg);
150
#else
151
  ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
152
  std::abort();
153
#endif
154
0
}
155
0
void ThrowStdOverflowError(const char* what_arg) {
156
0
#ifdef ABSL_HAVE_EXCEPTIONS
157
0
  throw std::overflow_error(what_arg);
158
#else
159
  ABSL_RAW_LOG(FATAL, "%s", what_arg);
160
  std::abort();
161
#endif
162
0
}
163
164
0
void ThrowStdUnderflowError(const std::string& what_arg) {
165
0
#ifdef ABSL_HAVE_EXCEPTIONS
166
0
  throw std::underflow_error(what_arg);
167
#else
168
  ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
169
  std::abort();
170
#endif
171
0
}
172
0
void ThrowStdUnderflowError(const char* what_arg) {
173
0
#ifdef ABSL_HAVE_EXCEPTIONS
174
0
  throw std::underflow_error(what_arg);
175
#else
176
  ABSL_RAW_LOG(FATAL, "%s", what_arg);
177
  std::abort();
178
#endif
179
0
}
180
181
0
void ThrowStdBadFunctionCall() {
182
0
#ifdef ABSL_HAVE_EXCEPTIONS
183
0
  throw std::bad_function_call();
184
#else
185
  std::abort();
186
#endif
187
0
}
188
189
0
void ThrowStdBadAlloc() {
190
0
#ifdef ABSL_HAVE_EXCEPTIONS
191
0
  throw std::bad_alloc();
192
#else
193
  std::abort();
194
#endif
195
0
}
196
197
0
void ThrowStdBadArrayNewLength() {
198
0
#ifdef ABSL_HAVE_EXCEPTIONS
199
0
  throw std::bad_array_new_length();
200
#else
201
  std::abort();
202
#endif
203
0
}
204
205
ABSL_NAMESPACE_END
206
}  // namespace absl