on master help sign in
More exception catching
commit8c528dd96f44c70bca32a4ac97deb8920ef1a5ad authorMichael Snoyman <michael@snoyman.com> dateMon 20 Sep 2010, 07:30 (16 years ago) parentccc4baa
3 files changed+10−6
Helper.hs+3 Network/Wai/Handler/DevelServer.hs+6−5 TestApp.hs+1−1
Helper.hsnew file+3
@@ -0,0 +1,3 @@
1+module Helper where
2+
3+db = "test.db3"
Network/Wai/Handler/DevelServer.hs+6−5
@@ -50,12 +50,15 @@ fillApp :: String -> String -> M.MVar Queue -> IO ()
5050fillApp modu func mqueue =
5151 go Nothing []
5252 where
53+ constSE :: x -> SomeException -> x
54+ constSE = const
55+ getTimes = handle (constSE $ return []) . mapM getModificationTime
5356 go prevError prevFiles = do
5457 toReload <-
5558 if null prevFiles
5659 then return True
5760 else do
58− times <- mapM (getModificationTime . fst) prevFiles
61+ times <- getTimes $ map fst prevFiles
5962 return $ times /= map snd prevFiles
6063 (newError, newFiles) <-
6164 if toReload
@@ -76,10 +79,8 @@ fillApp modu func mqueue =
7679 putStrLn "Interpreting success, new app loaded"
7780 E.handle onInitErr $ do
7881 swapApp app mqueue
79− files' <- forM files $ \f -> do
80− t <- getModificationTime f
81− return (f, t)
82− return (Nothing, files')
82+ times <- getTimes files
83+ return (Nothing, zip files times)
8384 onInitErr e = do
8485 putStrLn $ "Error initializing application: " ++ show e
8586 loadingApp' (Just e) mqueue
TestApp.hs+1−1
@@ -7,6 +7,7 @@ import Data.ByteString.Lazy.Char8 (pack)
77import Database.Persist.Sqlite
88import System.Directory
99import Control.Monad (when)
10+import Helper
1011
1112mkPersist [$persist|
1213Dummy
@@ -15,7 +16,6 @@ Dummy
1516
1617testApp handler = do
1718 putStrLn "testApp called, this should happen only once per reload"
18− let db = "test.db3"
1919 -- Swap between the following two lines as necessary to generate errors
2020 exi <- doesFileExist db
2121 --let exi = True