[GHC] #12096: Attach stacktrace information to SomeException

GHC ghc-devs at haskell.org
Tue Mar 28 16:17:08 UTC 2017


#12096: Attach stacktrace information to SomeException
-------------------------------------+-------------------------------------
        Reporter:  ndtimofeev        |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Core Libraries    |              Version:  8.0.1
      Resolution:                    |             Keywords:  Exceptions
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 simonmar):

 I quite like the idea of adding the call stack to `SomeException`
 actually.  A lot of rethrowing operations already do the right thing, e.g.
 `catchJust` works:

 {{{
 catchJust p a handler = catch a handler'
   where handler' e = case p e of
                         Nothing -> throwIO e
                         Just b  -> handler b
 }}}

 So does `onException`, and the things that use it (`bracket` etc.)

 {{{
 onException :: IO a -> IO b -> IO a
 onException io what = io `catch` \e -> do _ <- what
                                           throwIO (e :: SomeException)
 }}}

 So the places that don't work are those places that are using bare `catch`
 and re-throwing a more specific exception after doing some filtering on
 it.  For those we should recommend using `catchJust` when possible, and
 perhaps provide alternative APIs that allow more expressive filtering.  In
 the meantime there will be some places that get the wrong call stacks, but
 too bad - this is a debugging feature and as such doesn't need to be
 perfect.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12096#comment:20>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list