Project

General

Profile

Feature #8841

Add ability to hook into WException creation/destruction

Added by Roel Standaert 2 months ago. Updated 2 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
Start date:
07/23/2021
Due date:
% Done:

0%

Estimated time:

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 using std::any (with the caveat that copying an object into std::any should be 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 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.

#1

Updated by Roel Standaert 2 months ago

  • Description updated (diff)

Also available in: Atom PDF