@@ -479,9 +479,10 @@ namespace cpptrace {
479
479
480
480
### Logging
481
481
482
- Cpptrace attempts to gracefully recover from any internal errors. By default, cpptrace doesn't log anything to the
483
- console in order to avoid interfering with user programs. However, there are a couple configurations that can be used
484
- to set a custom logging behavior or enable logging to stderr.
482
+ Cpptrace attempts to gracefully recover from any internal errors in order to provide the best information it can and not
483
+ interfere with user applications. However, sometimes it's important to see what's going wrong inside cpptrace if
484
+ anything does go wrong. To facilitate this, cpptrace has an internal logger. By default it doesn't log anything out. The
485
+ following configurations that can be used to set a custom logging callback or enable logging to stderr:
485
486
486
487
``` cpp
487
488
namespace cpptrace {
@@ -577,23 +578,23 @@ CPPTRACE_TRY {
577
578
}
578
579
```
579
580
580
- > [!CAUTION]
581
- > There is a footgun with `return ` statements in these try /catch macros: The implementation on Windows requires wrapping
582
- > the try body in an immediately-invoked lambda and and as such `return ` statements return from the lambda not the
583
- > enclosing function. If you' re writing code that will be compiled on windows, it' s important to not write `return `
584
- > statements within CPPTRACE_TRY. E.g., this does not work as expected on windows:
581
+ > [!WARNING]
582
+ > There is an unfortunate limitation with `return ` statements in these try /catch macros: The implementation on Windows
583
+ > requires wrapping the try body in an immediately-invoked lambda and and as such `return ` statements would return from
584
+ > the lambda not the enclosing function. Cpptrace guards against misleading `return `s compiling by requiring the lambdas
585
+ > to return a special internal type, but, if you' re writing code that will be compiled on windows it' s important to not
586
+ > write `return ` statements within CPPTRACE_TRY. For example, this is invalid:
585
587
> ```cpp
586
588
> CPPTRACE_TRY {
587
- > if(condition) return 40; // does not return from the enclosing function on windows
589
+ > if(condition) return 40; // error, type int doesn't match cpptrace::detail::dont_return_from_try_catch_macros
588
590
> } CPPTRACE_CATCH(const std::exception& e) {
589
591
> ...
590
592
> }
591
- > return 20;
592
593
> ```
593
594
594
595
> [!WARNING]
595
- > There is one other footgun which is mainly relevant for code that was written on an older version of cpptrace: It's
596
- > possible to write the following without getting errors
596
+ > There is a footgun which is mainly relevant for code that was written on an older version of cpptrace: It's possible
597
+ > to write the following without getting errors
597
598
> ```cpp
598
599
> CPPTRACE_TRY {
599
600
> ...
@@ -603,9 +604,9 @@ CPPTRACE_TRY {
603
604
> ...
604
605
> }
605
606
> ```
606
- > This code will compile and in some sense work as expected as the second catch handler will work, however, cpptrace
607
- > won't know about the handler and as such it would be able to correctly collect a trace on a non- `std::runtime_error`
608
- > that is thrown. No run-time errors will occur, however, `from_current_exception` may report a misleading trace.
607
+ > This code will compile and the second catch handler will work, however, cpptrace won't know about the handler and as
608
+ > such it won't be able to correctly collect a trace when a type that does not match `std::runtime_error` is thrown. No
609
+ > run-time errors will occur, however, `from_current_exception` will report a misleading trace.
609
610
610
611
### Removing the `CPPTRACE_` prefix
611
612
0 commit comments