- 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
+ if isDoesNotExistError e then throw NotFound
+ else if isPermissionError e then throw Forbidden
+ else throw e
+ h <- liftIO (openBinaryFile file ReadMode) `catch` handleOpenError
+ (`onException` liftIO (hClose h)) $ do