Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Prevent hie crash if apply-refact crashes #1220

Merged
merged 4 commits into from
May 1, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Catch only ErrorCall and IOException
  • Loading branch information
Hogeyama committed Apr 30, 2019
commit a185f77e92d3dcb73e454e4cefad44cdc46cd9b1
10 changes: 7 additions & 3 deletions src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module Haskell.Ide.Engine.Plugin.ApplyRefact where

import Control.Arrow
import Control.Exception ( IOException
, SomeException
, ErrorCall
, Handler(..)
, catches
, try
)
import Control.Lens hiding ( List )
Expand Down Expand Up @@ -252,8 +254,10 @@ applyHint fp mhint fileMap = do
-- If we provide "applyRefactorings" with "Just (1,13)" then
-- the "Redundant bracket" hint will never be executed
-- because SrcSpan (1,20,??,??) doesn't contain position (1,13).
res <- liftIO
(try $ applyRefactorings Nothing commands fp :: IO (Either SomeException String))
res <- liftIO $ (Right <$> applyRefactorings Nothing commands fp) `catches`
[ Handler $ \e -> return (Left (show (e :: IOException)))
, Handler $ \e -> return (Left (show (e :: ErrorCall)))
]
case res of
Right appliedFile -> do
diff <- ExceptT $ Right <$> makeDiffResult fp (T.pack appliedFile) fileMap
Expand Down