From 77f754fa326f2a91ceeff260ff60c5096a07855b Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Fri, 15 Nov 2013 17:31:55 -0800 Subject: [PATCH] Replace Prelude.catch with Control.Exception.catch --- shellcheck.hs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/shellcheck.hs b/shellcheck.hs index 33019c0..328760b 100644 --- a/shellcheck.hs +++ b/shellcheck.hs @@ -15,10 +15,12 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . -} +import Control.Exception import Control.Monad import Data.Char import GHC.Exts import GHC.IO.Device +import Prelude hiding (catch) import ShellCheck.Simple import System.Console.GetOpt import System.Directory @@ -165,7 +167,7 @@ forCheckstyle options files = do putStrLn (formatFile file comments) return $ null comments report error = do - printErr $ show error + printErr $ show (error :: SomeException) return False severity "error" = "error" @@ -214,12 +216,14 @@ getOption (_:rest) flag def = getOption rest flag def main = do args <- getArgs parsedArgs <- parseArguments args - do + code <- do status <- process parsedArgs - if status then exitSuccess else exitWith (ExitFailure 1) - `catch` \err -> do - printErr $ show err - exitWith $ ExitFailure 2 + return $ if status then ExitSuccess else ExitFailure 1 + `catch` return + `catch` \err -> do + printErr $ show (err :: SomeException) + return $ ExitFailure 2 + exitWith code process Nothing = return False process (Just (options, files)) =