+readBinPackageDB file
+ = do xs <- Bin.decodeFile file
+ _ <- Exception.evaluate $ length xs
+ return xs
+ `catchUserError`
+ (\err -> error ("While parsing " ++ show file ++ ": " ++ err))
+
+catchUserError :: IO a -> (String -> IO a) -> IO a
+#ifdef BASE3
+catchUserError io f = io `Exception.catch` \e -> case e of
+ ErrorCall err -> f err
+ _ -> throw e
+#else
+catchUserError io f = io `Exception.catch` \(ErrorCall err) -> f err
+#endif