Draft: Print exception type metadata in default handler
Prerequisites
-
Merge test fix MRs -
Update array submodule here -
Update stm submodule here -
Update gitlab stm mirror
-
Intro
See https://github.com/haskell/core-libraries-committee/issues/231.
The linked issue requests metadata in the printed output for exceptions. For example:
main :: IO ()
main = throwBlocked
throwBlocked :: IO ()
throwBlocked = throwIO BlockedIndefinitelyOnMVar
Main: thread blocked indefinitely in an MVar operation
Package: base
Module: GHC.IO.Exception
Name: BlockedIndefinitelyOnMVar
With the future changes to use displayException
with callstacks (https://github.com/haskell/core-libraries-committee/issues/198), this may look like:
Main: thread blocked indefinitely in an MVar operation
HasCallStack backtrace:
CallStack (from HasCallStack):
collectBacktraces, called at libraries/base/GHC/Exception.hs:67:13 in base:GHC.Exception
toExceptionWithBacktrace, called at libraries/base/GHC/IO.hs:278:11 in base:GHC.IO
throwIO, called at Main.hs:15:16 in main:Main
Package: base
Module: GHC.IO.Exception
Name: BlockedIndefinitelyOnMVar
Notes
Note that this is rebased on top of the new exception context branch: wip/exception-context
. This is done for diff / future-rebasing purposes. I am not literally asking for this to be merged into the target branch, and I very much do not want to create any distractions for anyone working on that issue
2024-25-01: This is now branched off master, so it can be merged promptly.
Questions
-
I am not overly attached to the current output format: feedback welcome. For instance, we could have a compact form like:
λ. ./Main Main: thread blocked indefinitely in an MVar operation HasCallStack backtrace: CallStack (from HasCallStack): collectBacktraces, called at libraries/base/GHC/Exception.hs:67:13 in base:GHC.Exception toExceptionWithBacktrace, called at libraries/base/GHC/IO.hs:278:11 in base:GHC.IO throwIO, called at Main.hs:33:16 in main:Main Type: base:GHC.IO.Exception:BlockedIndefinitelyOnMVar
Also, the string concatenation is pretty gross, though maybe the simplicity is preferred, as we are already working with strings, and performance is unlikely to matter here.
Thanks!