]> andersk Git - scripts-static-cat.git/blobdiff - StaticCat.hs
Clean up open exception handling.
[scripts-static-cat.git] / StaticCat.hs
index 25be38899a5b007ca43395beb61afa3138e57145..be7fbe0ceccb1d4fd4b79221808c58e3992246ea 100644 (file)
@@ -131,13 +131,15 @@ serveFile file = (`catchExceptionCGI` outputMyError) $ do
 
   checkMethod $ do
 
-  h <- (`catchExceptionCGI` \e ->
-            if isDoesNotExistError e then throwExceptionCGI NotFound
-            else if isPermissionError e then throwExceptionCGI Forbidden
-            else throwExceptionCGI e) $
-        liftIO $ openBinaryFile file ReadMode
-  (`catchCGI` \e ->
-       (liftIO $ hClose h) >> throwCGI e) $ do
+  let handleOpenError e =
+          if isDoesNotExistError e then throwExceptionCGI NotFound
+          else if isPermissionError e then throwExceptionCGI Forbidden
+          else throwExceptionCGI e
+  h <- liftIO (openBinaryFile file ReadMode) `catchExceptionCGI` handleOpenError
+  let handlePostOpenError e = do
+        liftIO $ hClose h
+        throwCGI e
+  (`catchCGI` handlePostOpenError) $ do
 
   status <- liftIO $ hGetStatus h
   let mTime = modificationTime status
This page took 0.045463 seconds and 4 git commands to generate.