Feature #8841
closedAdd ability to hook into WException creation/destruction
0%
Description
There are many implementations for generating stack traces. Currently Wt supports libunwind, adding the stack trace to what()
, but there are many others.
When using services like Sentry it would be nice to use Sentry's own stack trace functionality, so it can be attached to the event sent to Sentry when the exception is caught.
To do this, we could add the ability for developers using Wt to globally register a hook that gets triggered upon creation (and maybe also deletion) of a WException
.
How the user would then attach their own stack trace information is still an open question. We could:
- Allow attaching arbitrary data to the
WException
usingstd::any
(with the caveat that copying an object intostd::any
should benoexcept
, since we should not have the constructor or destructor of an exception throw). We could also usevoid *
, but this may be more difficult to use correctly. - Just let the developer keep their own (thread safe) data structure that maps
WException
pointers to extra associated data. - Let the developer change the message.
There's also the caveat that if WException
is derived from, that type information is not available in the constructor or destructor of WException
. We currently have a few exception types that derive from WException
. We could just leave this as a caveat?
We can do something similar with Wt::Dbo::Exception
.
Updated by Roel Standaert over 2 years ago
- Target version deleted (
future)
We found a better way to do this, by hooking into __cxa_throw
, so we may not put this in Wt after all.
Updated by Roel Standaert about 2 years ago
- Status changed from New to Rejected
Setting this to rejected. We're no longer considering this for inclusion in Wt since there are methods like overriding __cxa_throw
that work better for all exceptions.