mirror of
https://github.com/haskell/haskell-language-server.git
synced 2024-09-11 08:45:35 +03:00
Improved message for missing command or plugin (#3285)
* No "PluginId" / "CommandId" prefix or quotes from show * No line break, but comma separated
This commit is contained in:
parent
55456fb281
commit
5cdaa245dd
@ -71,20 +71,26 @@ prettyResponseError err = errorCode <> ":" <+> errorBody
|
||||
errorBody = pretty $ err ^. LSP.message
|
||||
|
||||
pluginNotEnabled :: SMethod m -> [(PluginId, b, a)] -> Text
|
||||
pluginNotEnabled method availPlugins = "No plugin enabled for " <> T.pack (show method) <> ", available:\n" <> T.pack (unlines $ map (\(plid,_,_) -> show plid) availPlugins)
|
||||
pluginNotEnabled method availPlugins =
|
||||
"No plugin enabled for " <> T.pack (show method) <> ", available: "
|
||||
<> (T.intercalate ", " $ map (\(PluginId plid, _, _) -> plid) availPlugins)
|
||||
|
||||
pluginDoesntExist :: PluginId -> Text
|
||||
pluginDoesntExist (PluginId pid) = "Plugin " <> pid <> " doesn't exist"
|
||||
|
||||
commandDoesntExist :: CommandId -> PluginId -> [PluginCommand ideState] -> Text
|
||||
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)
|
||||
commandDoesntExist (CommandId com) (PluginId pid) legalCmds =
|
||||
"Command " <> com <> " isn't defined for plugin " <> pid <> ". Legal commands are: "
|
||||
<> (T.intercalate ", " $ map (\(PluginCommand{commandId = CommandId cid}) -> cid) legalCmds)
|
||||
|
||||
failedToParseArgs :: CommandId -- ^ command that failed to parse
|
||||
-> PluginId -- ^ Plugin that created the command
|
||||
-> String -- ^ The JSON Error message
|
||||
-> J.Value -- ^ The Argument Values
|
||||
-> Text
|
||||
failedToParseArgs (CommandId com) (PluginId pid) err arg = "Error while parsing args for " <> com <> " in plugin " <> pid <> ": " <> T.pack err <> "\narg = " <> T.pack (show arg)
|
||||
failedToParseArgs (CommandId com) (PluginId pid) err arg =
|
||||
"Error while parsing args for " <> com <> " in plugin " <> pid <> ": "
|
||||
<> T.pack err <> ", arg = " <> T.pack (show arg)
|
||||
|
||||
-- | Build a ResponseError and log it before returning to the caller
|
||||
logAndReturnError :: Recorder (WithPriority Log) -> PluginId -> ErrorCode -> Text -> LSP.LspT Config IO (Either ResponseError a)
|
||||
|
Loading…
Reference in New Issue
Block a user