Skip to content

Commit

Permalink
Add log message for missing cabal-fmt executable
Browse files Browse the repository at this point in the history
  • Loading branch information
fendor committed Nov 10, 2022
1 parent 97aefa4 commit cd91837
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/hls-cabal-fmt-plugin/src/Ide/Plugin/CabalFmt.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ data Log
= LogProcessInvocationFailure Int
| LogReadCreateProcessInfo String [String]
| LogInvalidInvocationInfo
| LogCabalFmtNotFound
deriving (Show)

instance Pretty Log where
Expand All @@ -31,6 +32,7 @@ instance Pretty Log where
["Invocation of cabal-fmt with arguments" <+> pretty args]
++ ["failed with standard error:" <+> pretty stdErrorOut | not (null stdErrorOut)]
LogInvalidInvocationInfo -> "Invocation of cabal-fmt with range was called but is not supported."
LogCabalFmtNotFound -> "Couldn't find executable 'cabal-fmt'"

descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState
descriptor recorder plId =
Expand Down Expand Up @@ -66,6 +68,7 @@ provider recorder _ide FormatText contents nfp opts = liftIO $ do
let fmtDiff = makeDiffTextEdit contents (T.pack out)
pure $ Right fmtDiff
Nothing -> do
log Error LogCabalFmtNotFound
pure $ Left (ResponseError InvalidRequest "No installation of cabal-fmt could be found. Please install it into your global environment." Nothing)
where
fp = fromNormalizedFilePath nfp
Expand Down

0 comments on commit cd91837

Please sign in to comment.