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