diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-11-19 18:01:43 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-11-23 18:57:49 -0500 |
commit | cb11fcb52ce8d5d1473a380db5fc0d32bf8ae75c (patch) | |
tree | 8640b62fe979e11a3a35dc167745f90b51dd20d8 | |
parent | 0e6c204570f77950c9019faa50ff867c158249c5 (diff) | |
download | haskell-cb11fcb52ce8d5d1473a380db5fc0d32bf8ae75c.tar.gz |
Packages: Don't use expectJust
Throw a slightly more informative error on failure. Motivated by the
errors seen in !2160.
-rw-r--r-- | compiler/main/Packages.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs index f5a8c964b3..baed7f5ec1 100644 --- a/compiler/main/Packages.hs +++ b/compiler/main/Packages.hs @@ -428,9 +428,11 @@ extendPackageConfigMap (PackageConfigMap pkg_map closure) new_pkgs -- | Looks up the package with the given id in the package state, panicing if it is -- not found -getPackageDetails :: DynFlags -> UnitId -> PackageConfig +getPackageDetails :: HasDebugCallStack => DynFlags -> UnitId -> PackageConfig getPackageDetails dflags pid = - expectJust "getPackageDetails" (lookupPackage dflags pid) + case lookupPackage dflags pid of + Just config -> config + Nothing -> pprPanic "getPackageDetails" (ppr pid) lookupInstalledPackage :: DynFlags -> InstalledUnitId -> Maybe PackageConfig lookupInstalledPackage dflags uid = lookupInstalledPackage' (pkgIdMap (pkgState dflags)) uid @@ -438,10 +440,11 @@ lookupInstalledPackage dflags uid = lookupInstalledPackage' (pkgIdMap (pkgState lookupInstalledPackage' :: PackageConfigMap -> InstalledUnitId -> Maybe PackageConfig lookupInstalledPackage' (PackageConfigMap db _) uid = lookupUDFM db uid -getInstalledPackageDetails :: DynFlags -> InstalledUnitId -> PackageConfig +getInstalledPackageDetails :: HasDebugCallStack => DynFlags -> InstalledUnitId -> PackageConfig getInstalledPackageDetails dflags uid = - expectJust "getInstalledPackageDetails" $ - lookupInstalledPackage dflags uid + case lookupInstalledPackage dflags uid of + Just config -> config + Nothing -> pprPanic "getInstalledPackageDetails" (ppr uid) -- | Get a list of entries from the package database. NB: be careful with -- this function, although all packages in this map are "visible", this |