[GHC] #12096: Attach stacktrace information to SomeException

GHC ghc-devs at haskell.org
Tue Mar 7 00:00:02 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:
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 ezyang):

 I know that `catchIO` and then `throwIO` if the `IOError` does not match a
 predicate is a common idiom. It's somewhat difficult to regex for them but
 if you grep for `throwIO` with a reference to a variable, there are tons
 and tons of them. Here are three random ones I picked out:

 {{{
 -- system-fileio
 removeTree root = do
         items <- listDirectory root
         forM_ items $ \item -> Exc.catch
                 (removeFile item)
                 (\exc -> do
                         isDir <- isRealDir item
                         if isDir
                                 then removeTree item
                                 else Exc.throwIO (exc :: IOError))

 -- HsSVN
              do err <- wrapSvnError =<< _fs_commit_txn
                                         conflictPathPtrPtr
                                         reposPtr
                                         newRevPtr
                                         txnPtr
                                         poolPtr
                 case err of
                   Nothing
                       -> liftM (Right . fromIntegral) (peek newRevPtr)

                   Just e
                       -> if svnErrCode e == FsConflict then
                              return . Left =<< peekCString =<< peek
 conflictPathPtrPtr
                          else
                              throwIO e


 -- DPM

             (Darcs.Lock.withLock fname (writeIORef ref True >> io))
               `catch` (\ (e::SomeException) ->
                            do b <- readIORef ref
                               if b then throwIO e
                                    else failIO ("Could not obtain lock "
                                                 ++ show fname ++
                                                ", aborting."))

 }}}

 I just grepped for `throwIO` and picked out three random examples that
 looked like they were rethrowing.

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


More information about the ghc-tickets mailing list