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

Commit a185f77

Browse files
committed
Catch only ErrorCall and IOException
1 parent 1042fde commit a185f77

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ module Haskell.Ide.Engine.Plugin.ApplyRefact where
66

77
import Control.Arrow
88
import Control.Exception ( IOException
9-
, SomeException
9+
, ErrorCall
10+
, Handler(..)
11+
, catches
1012
, try
1113
)
1214
import Control.Lens hiding ( List )
@@ -252,8 +254,10 @@ applyHint fp mhint fileMap = do
252254
-- If we provide "applyRefactorings" with "Just (1,13)" then
253255
-- the "Redundant bracket" hint will never be executed
254256
-- because SrcSpan (1,20,??,??) doesn't contain position (1,13).
255-
res <- liftIO
256-
(try $ applyRefactorings Nothing commands fp :: IO (Either SomeException String))
257+
res <- liftIO $ (Right <$> applyRefactorings Nothing commands fp) `catches`
258+
[ Handler $ \e -> return (Left (show (e :: IOException)))
259+
, Handler $ \e -> return (Left (show (e :: ErrorCall)))
260+
]
257261
case res of
258262
Right appliedFile -> do
259263
diff <- ExceptT $ Right <$> makeDiffResult fp (T.pack appliedFile) fileMap

0 commit comments

Comments
 (0)