|
5 | 5 | module Haskell.Ide.Engine.Plugin.ApplyRefact where
|
6 | 6 |
|
7 | 7 | import Control.Arrow
|
8 |
| -import Control.Lens hiding (List) |
| 8 | +import Control.Exception ( IOException |
| 9 | + , try |
| 10 | + ) |
| 11 | +import Control.Lens hiding ( List ) |
9 | 12 | import Control.Monad.IO.Class
|
10 | 13 | import Control.Monad.Trans.Except
|
11 | 14 | import Data.Aeson hiding (Error)
|
@@ -105,14 +108,25 @@ lintCmd = CmdSync $ \uri -> do
|
105 | 108 | -- AZ:TODO: Why is this in IdeGhcM?
|
106 | 109 | lintCmd' :: Uri -> IdeGhcM (IdeResult PublishDiagnosticsParams)
|
107 | 110 | lintCmd' uri = pluginGetFile "lintCmd: " uri $ \fp -> do
|
108 |
| - res <- GM.withMappedFile fp $ \file' -> liftIO $ runExceptT $ runLintCmd file' [] |
109 |
| - case res of |
110 |
| - Left diags -> |
111 |
| - return (IdeResultOk (PublishDiagnosticsParams (filePathToUri fp) $ List diags)) |
112 |
| - Right fs -> |
113 |
| - return $ IdeResultOk $ |
114 |
| - PublishDiagnosticsParams (filePathToUri fp) |
115 |
| - $ List (map hintToDiagnostic $ stripIgnores fs) |
| 111 | + eitherErrorResult <- GM.withMappedFile fp $ \file' -> |
| 112 | + liftIO (try $ runExceptT $ runLintCmd file' [] :: IO (Either IOException (Either [Diagnostic] [Idea]))) |
| 113 | + |
| 114 | + case eitherErrorResult of |
| 115 | + Left err -> |
| 116 | + return |
| 117 | + $ IdeResultFail (IdeError PluginError |
| 118 | + (T.pack $ "lintCmd: " ++ show err) Null) |
| 119 | + Right res -> case res of |
| 120 | + Left diags -> |
| 121 | + return |
| 122 | + (IdeResultOk |
| 123 | + (PublishDiagnosticsParams (filePathToUri fp) $ List diags) |
| 124 | + ) |
| 125 | + Right fs -> |
| 126 | + return |
| 127 | + $ IdeResultOk |
| 128 | + $ PublishDiagnosticsParams (filePathToUri fp) |
| 129 | + $ List (map hintToDiagnostic $ stripIgnores fs) |
116 | 130 |
|
117 | 131 | runLintCmd :: FilePath -> [String] -> ExceptT [Diagnostic] IO [Idea]
|
118 | 132 | runLintCmd fp args = do
|
|
0 commit comments