--
-----------------------------------------------------------------------------
+-- #hide
module GHC.TopHandler (
runMainIO, runIO, runNonIO, reportStackOverflow, reportError
) where
-- | 'runMainIO' is wrapped around 'Main.main' (or whatever main is
-- called in the program). It catches otherwise uncaught exceptions,
--- and also flushes stdout/stderr before exiting.
+-- and also flushes stdout\/stderr before exiting.
runMainIO :: IO a -> IO a
runMainIO main = (do a <- main; cleanUp; return a) `catchException` topHandler
--
real_handler :: Exception -> IO a
real_handler ex =
+ cleanUp >>
case ex of
AsyncException StackOverflow -> do
reportStackOverflow