Skip to content

Commit ea10ba8

Browse files
committed
Improved message for missing command or plugin
* No "PluginId" / "CommandId" prefix or quotes from show * No line break, but comma separated
1 parent 86e3fd6 commit ea10ba8

File tree

1 file changed

+9
-3
lines changed
  • ghcide/src/Development/IDE/Plugin

1 file changed

+9
-3
lines changed

Diff for: ghcide/src/Development/IDE/Plugin/HLS.hs

+9-3
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,26 @@ prettyResponseError err = errorCode <> ":" <+> errorBody
7171
errorBody = pretty $ err ^. LSP.message
7272

7373
pluginNotEnabled :: SMethod m -> [(PluginId, b, a)] -> Text
74-
pluginNotEnabled method availPlugins = "No plugin enabled for " <> T.pack (show method) <> ", available:\n" <> T.pack (unlines $ map (\(plid,_,_) -> show plid) availPlugins)
74+
pluginNotEnabled method availPlugins =
75+
"No plugin enabled for " <> T.pack (show method) <> ", available: "
76+
<> (T.intercalate ", " $ map (\(PluginId plid, _, _) -> plid) availPlugins)
7577

7678
pluginDoesntExist :: PluginId -> Text
7779
pluginDoesntExist (PluginId pid) = "Plugin " <> pid <> " doesn't exist"
7880

7981
commandDoesntExist :: CommandId -> PluginId -> [PluginCommand ideState] -> Text
80-
commandDoesntExist (CommandId com) (PluginId pid) legalCmds = "Command " <> com <> " isn't defined for plugin " <> pid <> ". Legal commands are:\n" <> T.pack (unlines $ map (show . commandId) legalCmds)
82+
commandDoesntExist (CommandId com) (PluginId pid) legalCmds =
83+
"Command " <> com <> " isn't defined for plugin " <> pid <> ". Legal commands are: "
84+
<> (T.intercalate ", " $ map (\(PluginCommand{commandId = CommandId cid}) -> cid) legalCmds)
8185

8286
failedToParseArgs :: CommandId -- ^ command that failed to parse
8387
-> PluginId -- ^ Plugin that created the command
8488
-> String -- ^ The JSON Error message
8589
-> J.Value -- ^ The Argument Values
8690
-> Text
87-
failedToParseArgs (CommandId com) (PluginId pid) err arg = "Error while parsing args for " <> com <> " in plugin " <> pid <> ": " <> T.pack err <> "\narg = " <> T.pack (show arg)
91+
failedToParseArgs (CommandId com) (PluginId pid) err arg =
92+
"Error while parsing args for " <> com <> " in plugin " <> pid <> ": "
93+
<> T.pack err <> ", arg = " <> T.pack (show arg)
8894

8995
-- | Build a ResponseError and log it before returning to the caller
9096
logAndReturnError :: Recorder (WithPriority Log) -> PluginId -> ErrorCode -> Text -> LSP.LspT Config IO (Either ResponseError a)

0 commit comments

Comments
 (0)