@@ -75,6 +75,7 @@ data SnapshotException
7575 | NeedResolverOrCompiler ! Text
7676 | MissingPackages ! (Set PackageName )
7777 | CustomResolverException ! Text ! (Either Request FilePath ) ! ParseException
78+ | InvalidStackageException ! SnapName ! String
7879 deriving Typeable
7980instance Exception SnapshotException
8081instance Show SnapshotException where
@@ -124,10 +125,20 @@ instance Show SnapshotException where
124125 show (CustomResolverException url loc e) = concat
125126 [ " Unable to load custom resolver "
126127 , T. unpack url
127- , " from location\n "
128- , show loc
128+ , " from "
129+ , case loc of
130+ Left _req -> " HTTP request"
131+ Right fp -> " local file:\n " ++ fp
129132 , " \n Exception: "
130- , show e
133+ , case e of
134+ AesonException s -> s
135+ _ -> show e
136+ ]
137+ show (InvalidStackageException snapName e) = concat
138+ [ " Unable to parse Stackage snapshot "
139+ , T. unpack (renderSnapName snapName)
140+ , " : "
141+ , e
131142 ]
132143
133144-- | Convert a 'Resolver' into a 'SnapshotDef'
@@ -146,7 +157,7 @@ loadResolver (ResolverStackage name) = do
146157 Left e -> throwIO e
147158 Right value ->
148159 case parseEither parseStackageSnapshot value of
149- Left s -> throwIO $ AesonException s
160+ Left s -> throwIO $ InvalidStackageException name s
150161 Right x -> return x
151162 logDebug $ " Decoding build plan from: " <> T. pack (toFilePath fp)
152163 eres <- tryDecode
@@ -277,7 +288,7 @@ loadResolver (ResolverCustom url loc) = do
277288 WithJSONWarnings (sd0, mparentResolver, mcompiler) warnings <-
278289 liftIO (decodeFileEither fp) >>= either
279290 (throwM . CustomResolverException url loc)
280- (either (throwM . AesonException ) return . parseEither parseCustom)
291+ (either (throwM . CustomResolverException url loc . AesonException ) return . parseEither parseCustom)
281292 logJSONWarnings (T. unpack url) warnings
282293 forM_ (sdLocations sd0) $ \ loc' ->
283294 case loc' of
0 commit comments