Permalink
Browse files

* Port afp-scanudc.hs to new-style exception handling.

  • Loading branch information...
1 parent 0419a5c commit 1fe541a998d6d0b1d476d1cbcf06f1d5ea182986 @audreyt committed Aug 29, 2011
Showing with 6 additions and 5 deletions.
  1. +6 −5 afp-scanudc.hs
View
@@ -48,18 +48,19 @@ main = do
scanUDC :: FilePath -> IO Bool
scanUDC file = do
- rv <- E.try $ readAFP file
+ rv <- E.try $ readAFP file :: IO (Either SomeException [AFP_])
case rv of
Right cs -> (`E.catch` hdl) $ do
let ptxs = length cs `seq` filter (~~ _PTX) cs
mapM_ (scanPTX . decodeChunk) ptxs
return False
- _ -> return False -- skip non-afp files
+ _ -> return False -- skip non-afp files
where
tryOpen = openBinaryFile file ReadMode `E.catch` tryErr
- tryErr (E.IOException ioe) | isFullError ioe = threadDelay 200 >> tryOpen
- tryErr e = E.throwIO e
- hdl (E.IOException ioe) | Just e <- cast ioe, isUserError e = return True
+ tryErr e | Just ioe <- cast e, isFullError ioe = threadDelay 200 >> tryOpen
+ tryErr e = E.throwIO (e :: SomeException)
+ hdl :: SomeException -> IO Bool
+ hdl e | Just ioe <- cast e, isUserError ioe = return True
hdl _ = return False
scanPTX :: PTX -> IO ()

0 comments on commit 1fe541a

Please sign in to comment.