@@ -58,16 +58,22 @@ import Stack.Types.SourceMap
58
58
( ProjectPackage (.. ), SMWanted (.. ), ppComponentsMaybe )
59
59
import System.IO ( putStrLn )
60
60
61
- -- | Type representing exceptions thrown by functions exported by the
61
+ -- | Type representing \'pretty\' exceptions thrown by functions exported by the
62
62
-- "Stack.IDE" module.
63
- newtype IdeException
64
- = MissingFileTarget String
63
+ newtype IdePrettyException
64
+ = FileTargetIsInvalidAbsFile String
65
65
deriving (Show , Typeable )
66
66
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
71
77
72
78
-- | Function underlying the @stack ide packages@ command. List packages in the
73
79
-- project.
@@ -196,7 +202,7 @@ preprocessTarget rawTarget =
196
202
let fp = T. unpack rawTarget
197
203
mpath <- forgivingResolveFile' fp
198
204
case mpath of
199
- Nothing -> throwM ( MissingFileTarget fp)
205
+ Nothing -> prettyThrowM ( FileTargetIsInvalidAbsFile fp)
200
206
Just path -> pure path
201
207
pure (Just fileTarget)
202
208
else pure Nothing
0 commit comments