summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
f41e3ea)
We used to just get
ghc: panic! (the 'impossible' happened)
(GHC version 6.13.
20091128 for x86_64-unknown-linux):
too few bytes. Failed reading at byte position 32753
with no indication of what was being parsed.
import Distribution.License
import Distribution.InstalledPackageInfo as IPI
import Data.Binary as Bin
import Distribution.License
import Distribution.InstalledPackageInfo as IPI
import Data.Binary as Bin
+import Control.Exception as Exception
readBinPackageDB :: Binary m => FilePath -> IO [InstalledPackageInfo_ m]
readBinPackageDB :: Binary m => FilePath -> IO [InstalledPackageInfo_ m]
-readBinPackageDB file = Bin.decodeFile file
+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
writeBinPackageDB :: Binary m => FilePath -> [InstalledPackageInfo_ m] -> IO ()
writeBinPackageDB file ipis = Bin.encodeFile file ipis
writeBinPackageDB :: Binary m => FilePath -> [InstalledPackageInfo_ m] -> IO ()
writeBinPackageDB file ipis = Bin.encodeFile file ipis
type: darcs
location: http://darcs.haskell.org/ghc
type: darcs
location: http://darcs.haskell.org/ghc
+flag base3
+ default: False
+
Library {
exposed-modules:
Distribution.InstalledPackageInfo.Binary
Library {
exposed-modules:
Distribution.InstalledPackageInfo.Binary
- build-depends: base >= 3 && < 5,
- binary == 0.5.*,
+ if flag(base3)
+ build-depends: base >= 3 && < 4
+ cpp-options: -DBASE3
+ else
+ build-depends: base >= 4 && < 5
+
+ build-depends: binary == 0.5.*,