-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rethrow without modifying cpptrace::from_current_exception? #214
Comments
Hi, It took me a moment to understand the hack you found. That does indeed seem to work, though unfortunately it wouldn't for the Another thought is that when flipping the trace switch and rethrowing like this outer Another solution might be try to rethrow with an exception object that stores the trace, but this isn't without downsides either. |
I think for my use case I don’t really need the trace from where the rethrow happened, but I agree that keeping the whole stack of rethrow backtracks around is nice for completeness sake. Is this something you’d like to see a PR for, or do you want to mull over the design a bit first? |
I'd welcome a PR! We need something that will work for both the Z and non-Z variants of the try/catch macros and something that won't add notably cost in the non-throwing path. This might have to be done with std::exception_ptr trickery but I'm open to various approaches. |
OK - I'll try and get to something this week. Thanks for the pointers! |
If you've got nested
CPPTRACE_TRY
/CPPTRACE_CATCH
blocks, like this:The second call to
put_exception_on_opentelemetry_span
sees the backtrace coming from the re-throw in the innerCPPTRACE_CATCH
block. It would be nice if we could rethrow without losing the original call stack.My use case for this is to be able to put error backtraces on OpenTelemetry spans; without something like this, the bottom frame of all but the innermost span would be the re-throw at the top of the previous span.
I actually was able to hack something to make it work for my usecase:
which seems to work... is this something we should expose a macro or function for?
CPPTRACE_RETHROW
or something?The text was updated successfully, but these errors were encountered: