@@ -58,16 +58,22 @@ import Stack.Types.SourceMap
5858 ( ProjectPackage (.. ), SMWanted (.. ), ppComponentsMaybe )
5959import System.IO ( putStrLn )
6060
61- -- | Type representing exceptions thrown by functions exported by the
61+ -- | Type representing \'pretty\' exceptions thrown by functions exported by the
6262-- "Stack.IDE" module.
63- newtype IdeException
64- = MissingFileTarget String
63+ newtype IdePrettyException
64+ = FileTargetIsInvalidAbsFile String
6565 deriving (Show , Typeable )
6666
67- instance Exception IdeException where
68- displayException (MissingFileTarget name) =
69- " Error: [S-9208]\n "
70- ++ " Cannot find file target " ++ name ++ " ."
67+ instance Pretty IdePrettyException where
68+ pretty (FileTargetIsInvalidAbsFile name) =
69+ " [S-9208]"
70+ <> line
71+ <> fillSep
72+ [ flow " Cannot work out a valid path for file target"
73+ , style File (fromString name) <> " ."
74+ ]
75+
76+ instance Exception IdePrettyException
7177
7278-- | Function underlying the @stack ide packages@ command. List packages in the
7379-- project.
@@ -196,7 +202,7 @@ preprocessTarget rawTarget =
196202 let fp = T. unpack rawTarget
197203 mpath <- forgivingResolveFile' fp
198204 case mpath of
199- Nothing -> throwM ( MissingFileTarget fp)
205+ Nothing -> prettyThrowM ( FileTargetIsInvalidAbsFile fp)
200206 Just path -> pure path
201207 pure (Just fileTarget)
202208 else pure Nothing
0 commit comments