5
5
#include < cstdint>
6
6
#include < cstdio>
7
7
#include < cstring>
8
+ #include < exception>
8
9
#include < iostream>
9
10
#include < sstream>
10
11
#include < string>
@@ -39,9 +40,7 @@ CPPTRACE_BEGIN_NAMESPACE
39
40
try { // try/catch can never be hit but it's needed to prevent TCO
40
41
return generate_raw_trace (skip + 1 );
41
42
} catch (...) {
42
- if (!detail::should_absorb_trace_exceptions ()) {
43
- throw ;
44
- }
43
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
45
44
return raw_trace{};
46
45
}
47
46
}
@@ -51,9 +50,7 @@ CPPTRACE_BEGIN_NAMESPACE
51
50
try { // try/catch can never be hit but it's needed to prevent TCO
52
51
return generate_raw_trace (skip + 1 , max_depth);
53
52
} catch (...) {
54
- if (!detail::should_absorb_trace_exceptions ()) {
55
- throw ;
56
- }
53
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
57
54
return raw_trace{};
58
55
}
59
56
}
@@ -62,9 +59,7 @@ CPPTRACE_BEGIN_NAMESPACE
62
59
try {
63
60
return object_trace{detail::get_frames_object_info (frames)};
64
61
} catch (...) { // NOSONAR
65
- if (!detail::should_absorb_trace_exceptions ()) {
66
- throw ;
67
- }
62
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
68
63
return object_trace{};
69
64
}
70
65
}
@@ -77,9 +72,7 @@ CPPTRACE_BEGIN_NAMESPACE
77
72
}
78
73
return {std::move (trace)};
79
74
} catch (...) { // NOSONAR
80
- if (!detail::should_absorb_trace_exceptions ()) {
81
- throw ;
82
- }
75
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
83
76
return stacktrace{};
84
77
}
85
78
}
@@ -97,9 +90,7 @@ CPPTRACE_BEGIN_NAMESPACE
97
90
try { // try/catch can never be hit but it's needed to prevent TCO
98
91
return generate_object_trace (skip + 1 );
99
92
} catch (...) {
100
- if (!detail::should_absorb_trace_exceptions ()) {
101
- throw ;
102
- }
93
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
103
94
return object_trace{};
104
95
}
105
96
}
@@ -109,9 +100,7 @@ CPPTRACE_BEGIN_NAMESPACE
109
100
try { // try/catch can never be hit but it's needed to prevent TCO
110
101
return generate_object_trace (skip + 1 , max_depth);
111
102
} catch (...) {
112
- if (!detail::should_absorb_trace_exceptions ()) {
113
- throw ;
114
- }
103
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
115
104
return object_trace{};
116
105
}
117
106
}
@@ -124,9 +113,7 @@ CPPTRACE_BEGIN_NAMESPACE
124
113
}
125
114
return {std::move (trace)};
126
115
} catch (...) { // NOSONAR
127
- if (!detail::should_absorb_trace_exceptions ()) {
128
- throw ;
129
- }
116
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
130
117
return stacktrace ();
131
118
}
132
119
}
@@ -160,9 +147,7 @@ CPPTRACE_BEGIN_NAMESPACE
160
147
try { // try/catch can never be hit but it's needed to prevent TCO
161
148
return generate_trace (skip + 1 );
162
149
} catch (...) {
163
- if (!detail::should_absorb_trace_exceptions ()) {
164
- throw ;
165
- }
150
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
166
151
return stacktrace{};
167
152
}
168
153
}
@@ -172,9 +157,7 @@ CPPTRACE_BEGIN_NAMESPACE
172
157
try { // try/catch can never be hit but it's needed to prevent TCO
173
158
return generate_trace (skip + 1 , max_depth);
174
159
} catch (...) {
175
- if (!detail::should_absorb_trace_exceptions ()) {
176
- throw ;
177
- }
160
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
178
161
return stacktrace{};
179
162
}
180
163
}
@@ -225,9 +208,7 @@ CPPTRACE_BEGIN_NAMESPACE
225
208
try {
226
209
return raw_trace{detail::capture_frames (skip + 1 , SIZE_MAX)};
227
210
} catch (...) { // NOSONAR
228
- if (!detail::should_absorb_trace_exceptions ()) {
229
- throw ;
230
- }
211
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
231
212
return raw_trace{};
232
213
}
233
214
}
@@ -237,9 +218,7 @@ CPPTRACE_BEGIN_NAMESPACE
237
218
try {
238
219
return raw_trace{detail::capture_frames (skip + 1 , max_depth)};
239
220
} catch (...) { // NOSONAR
240
- if (!detail::should_absorb_trace_exceptions ()) {
241
- throw ;
242
- }
221
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
243
222
return raw_trace{};
244
223
}
245
224
}
@@ -249,9 +228,7 @@ CPPTRACE_BEGIN_NAMESPACE
249
228
try { // try/catch can never be hit but it's needed to prevent TCO
250
229
return detail::safe_capture_frames (buffer, size, skip + 1 , SIZE_MAX);
251
230
} catch (...) {
252
- if (!detail::should_absorb_trace_exceptions ()) {
253
- throw ;
254
- }
231
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
255
232
return 0 ;
256
233
}
257
234
}
@@ -266,9 +243,7 @@ CPPTRACE_BEGIN_NAMESPACE
266
243
try { // try/catch can never be hit but it's needed to prevent TCO
267
244
return detail::safe_capture_frames (buffer, size, skip + 1 , max_depth);
268
245
} catch (...) {
269
- if (!detail::should_absorb_trace_exceptions ()) {
270
- throw ;
271
- }
246
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
272
247
return 0 ;
273
248
}
274
249
}
@@ -278,9 +253,7 @@ CPPTRACE_BEGIN_NAMESPACE
278
253
try {
279
254
return object_trace{detail::get_frames_object_info (detail::capture_frames (skip + 1 , SIZE_MAX))};
280
255
} catch (...) { // NOSONAR
281
- if (!detail::should_absorb_trace_exceptions ()) {
282
- throw ;
283
- }
256
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
284
257
return object_trace{};
285
258
}
286
259
}
@@ -290,9 +263,7 @@ CPPTRACE_BEGIN_NAMESPACE
290
263
try {
291
264
return object_trace{detail::get_frames_object_info (detail::capture_frames (skip + 1 , max_depth))};
292
265
} catch (...) { // NOSONAR
293
- if (!detail::should_absorb_trace_exceptions ()) {
294
- throw ;
295
- }
266
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
296
267
return object_trace{};
297
268
}
298
269
}
@@ -302,9 +273,7 @@ CPPTRACE_BEGIN_NAMESPACE
302
273
try { // try/catch can never be hit but it's needed to prevent TCO
303
274
return generate_trace (skip + 1 , SIZE_MAX);
304
275
} catch (...) {
305
- if (!detail::should_absorb_trace_exceptions ()) {
306
- throw ;
307
- }
276
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
308
277
return stacktrace{};
309
278
}
310
279
}
@@ -319,9 +288,7 @@ CPPTRACE_BEGIN_NAMESPACE
319
288
}
320
289
return {std::move (trace)};
321
290
} catch (...) { // NOSONAR
322
- if (!detail::should_absorb_trace_exceptions ()) {
323
- throw ;
324
- }
291
+ detail::log_and_maybe_propagate_exception (std::current_exception ());
325
292
return stacktrace ();
326
293
}
327
294
}
0 commit comments