
#12096: Attach stacktrace information to SomeException -------------------------------------+------------------------------------- Reporter: ndtimofeev | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by gridaphobe): I'm generally in favor of adding `CallStack`s to exceptions (I've often cursed myself for using exceptions and having no clue where they were thrown). I'm not sure this is the best API though. A few thoughts: 1. I would prefer to not serialize the `CallStack`, i.e. get rid of `prettyCallStack`. Clients might want to inspect the `CallStack` when they catch an exception. 2. I wonder if adding the `CallStack` to `SomeException` is the best move. If we do this, we're kinda limited to adding the stack to `SomeException`s `Show` instance. People (AFAIK) don't usually operate directly on `SomeException`, they use `catch` and co. to unwrap the exception, which means giving up the `CallStack`. On the other hand, expecting users to add `CallStack`s to each exception type is not practical, nor is it clear how we'd wire that into `throw`. Perhaps (2) can be solved by keeping the `CallStack` in `SomeException` and adding a few helper functions, e.g. {{{#!haskell catchWithCallStack :: Exception e => IO a -> (e -> CallStack -> IO a) -> IO a }}} Thanks for the suggestion! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12096#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler