File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 1
1
#include < cpptrace/cpptrace.hpp>
2
- #include < cpptrace/version .hpp>
2
+ #include < cpptrace/from_current .hpp>
3
3
4
4
#include < algorithm>
5
5
#include < cctype>
6
6
#include < iostream>
7
7
#include < string>
8
8
9
- void trace () {
10
- cpptrace::generate_trace ().print ();
11
- cpptrace::generate_trace ().print_with_snippets ();
12
- throw cpptrace::logic_error (" foobar" );
9
+ void fail () {
10
+ throw std::runtime_error (" foobar" );
13
11
}
14
12
15
13
void foo (int n) {
16
14
if (n == 0 ) {
17
- trace ();
15
+ fail ();
18
16
} else {
19
17
foo (n - 1 );
20
18
}
@@ -37,5 +35,10 @@ int main() {
37
35
cpptrace::absorb_trace_exceptions (false );
38
36
cpptrace::use_default_stderr_logger ();
39
37
cpptrace::register_terminate_handler ();
40
- function_one (0 );
38
+ CPPTRACE_TRY {
39
+ function_one (0 );
40
+ } CPPTRACE_CATCH (const std::exception& e) {
41
+ std::cout << " Exception caught: " << e.what () << std::endl;
42
+ cpptrace::from_current_exception ().print ();
43
+ }
41
44
}
You can’t perform that action at this time.
0 commit comments