File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change 11#include < cpptrace/cpptrace.hpp>
2- #include < cpptrace/version .hpp>
2+ #include < cpptrace/from_current .hpp>
33
44#include < algorithm>
55#include < cctype>
66#include < iostream>
77#include < string>
88
9- void trace () {
9+ void fail () {
10+ std::cout << " Throwing an exception from:" << std::endl;
1011 cpptrace::generate_trace ().print ();
11- cpptrace::generate_trace ().print_with_snippets ();
12- throw cpptrace::logic_error (" foobar" );
12+ throw std::runtime_error (" foobar" );
1313}
1414
1515void foo (int n) {
1616 if (n == 0 ) {
17- trace ();
17+ fail ();
1818 } else {
1919 foo (n - 1 );
2020 }
@@ -37,5 +37,10 @@ int main() {
3737 cpptrace::absorb_trace_exceptions (false );
3838 cpptrace::use_default_stderr_logger ();
3939 cpptrace::register_terminate_handler ();
40- function_one (0 );
40+ CPPTRACE_TRY {
41+ function_one (0 );
42+ } CPPTRACE_CATCH (const std::exception& e) {
43+ std::cout << " Exception caught: " << e.what () << std::endl;
44+ cpptrace::from_current_exception ().print ();
45+ }
4146}
You can’t perform that action at this time.
0 commit comments