Add ability to hook into WException creation/destruction
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
How the user would then attach their own stack trace information is still an open question. We could:
- Allow attaching arbitrary data to the
std::any(with the caveat that copying an object into
noexcept, since we should not have the constructor or destructor of an exception throw). We could also use
void *, but this may be more difficult to use correctly.
- Just let the developer keep their own (thread safe) data structure that maps
WExceptionpointers 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