Coverage Report

Created: 2026-02-14 07:09

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