Replace Prelude.catch with Control.Exception.catch

This commit is contained in:
Vidar Holen 2013-11-15 17:31:55 -08:00
parent 01d557abe6
commit 77f754fa32
1 changed files with 10 additions and 6 deletions

View File

@ -15,10 +15,12 @@
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
-} -}
import Control.Exception
import Control.Monad import Control.Monad
import Data.Char import Data.Char
import GHC.Exts import GHC.Exts
import GHC.IO.Device import GHC.IO.Device
import Prelude hiding (catch)
import ShellCheck.Simple import ShellCheck.Simple
import System.Console.GetOpt import System.Console.GetOpt
import System.Directory import System.Directory
@ -165,7 +167,7 @@ forCheckstyle options files = do
putStrLn (formatFile file comments) putStrLn (formatFile file comments)
return $ null comments return $ null comments
report error = do report error = do
printErr $ show error printErr $ show (error :: SomeException)
return False return False
severity "error" = "error" severity "error" = "error"
@ -214,12 +216,14 @@ getOption (_:rest) flag def = getOption rest flag def
main = do main = do
args <- getArgs args <- getArgs
parsedArgs <- parseArguments args parsedArgs <- parseArguments args
do code <- do
status <- process parsedArgs status <- process parsedArgs
if status then exitSuccess else exitWith (ExitFailure 1) return $ if status then ExitSuccess else ExitFailure 1
`catch` \err -> do `catch` return
printErr $ show err `catch` \err -> do
exitWith $ ExitFailure 2 printErr $ show (err :: SomeException)
return $ ExitFailure 2
exitWith code
process Nothing = return False process Nothing = return False
process (Just (options, files)) = process (Just (options, files)) =