More control over Backtraces formatting
(This is a follow-up ticket to https://discourse.haskell.org/t/solved-how-to-reliably-get-callstacks-with-ghc-9-10/12101/17?u=kleidukos, please read the final post beforehand)
Upon an exception in my application, I want to be able to send the stack frames collected by cost centers to a third-party service like Sentry.
I get a pretty useful trace from manually retrieving exception contexts and I'd like to render:
Server.handleDB (src/Server.hs:77:11-39)
Server.handleDB (src/Server.hs:77:20-39)
Database.PostgreSQL.Simple.Internal.connectPostgreSQL (src/Database/PostgreSQL/Simple/Internal.hs:(262,29)-(279,34))
Database.PostgreSQL.Simple.Internal.connectPostgreSQL (src/Database/PostgreSQL/Simple/Internal.hs:263:13-29)
to an array of JSON objects, suitable for the Sentry API. This allow for showing precise provenance of an exception in production.
Unfortunately it seems today that displayExceptionContext
calls the displayExceptionAnnotation
method for Backtraces, which is an opaque data type with only one way to render to a string.
I'd like to have more control over the formatting of Backtraces
' cost center stack, by ideally getting the Maybe (Ptr CCS.CostCentreStack)
out of Backtraces
, so that I may perform my own formatting and thus reporting.