diff options
author | Spencer Janssen <sjanssen@cse.unl.edu> | 2007-10-12 17:28:01 +0200 |
---|---|---|
committer | Spencer Janssen <sjanssen@cse.unl.edu> | 2007-10-12 17:28:01 +0200 |
commit | f5a5c67a06608691b44b625c8aff2c4dc9b2d392 (patch) | |
tree | bacc45f67f2966090f68875b4d3eb3b0b505dc91 | |
parent | 79a2509eec15de0b88df078a9f8b19cd39b241a7 (diff) | |
download | xmonad-f5a5c67a06608691b44b625c8aff2c4dc9b2d392.tar.gz xmonad-f5a5c67a06608691b44b625c8aff2c4dc9b2d392.tar.xz xmonad-f5a5c67a06608691b44b625c8aff2c4dc9b2d392.zip |
Respect ExitExceptions, fixes a regression where exitWith had no effect
darcs-hash:20071012152801-a5988-80a14dda451e1e6e7cdc9e42fdc11568c21004b2.gz
-rw-r--r-- | Main.hs | 1 | ||||
-rw-r--r-- | XMonad.hs | 10 |
2 files changed, 7 insertions, 4 deletions
@@ -103,6 +103,7 @@ main = do -- main loop, for all you HOF/recursion fans out there. forever_ $ handle =<< io (nextEvent dpy e >> getEvent e) + return () where forever_ a = a >> forever_ a -- --------------------------------------------------------------------- @@ -25,7 +25,7 @@ module XMonad ( import StackSet import Prelude hiding ( catch ) -import Control.Exception ( catch ) +import Control.Exception (catch, throw, Exception(ExitException)) import Control.Monad.State import Control.Monad.Reader import System.IO @@ -87,11 +87,13 @@ runX c st (X a) = runStateT (runReaderT a c) st -- | Run in the X monad, and in case of exception, and catch it and log it -- to stderr, and run the error case. catchX :: X a -> X a -> X a -catchX (X job) (X errcase) = do +catchX job errcase = do st <- get c <- ask - (a,s') <- io ((runStateT (runReaderT job c) st) `catch` - \e -> (do hPutStrLn stderr (show e); runStateT (runReaderT errcase c) st)) + (a, s') <- io $ runX c st job `catch` + \e -> case e of + ExitException {} -> throw e + _ -> do hPrint stderr e; runX c st errcase put s' return a |