Replace Prelude.catch with Control.Exception.catch
This commit is contained in:
parent
01d557abe6
commit
77f754fa32
|
@ -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` return
|
||||||
`catch` \err -> do
|
`catch` \err -> do
|
||||||
printErr $ show err
|
printErr $ show (err :: SomeException)
|
||||||
exitWith $ ExitFailure 2
|
return $ ExitFailure 2
|
||||||
|
exitWith code
|
||||||
|
|
||||||
process Nothing = return False
|
process Nothing = return False
|
||||||
process (Just (options, files)) =
|
process (Just (options, files)) =
|
||||||
|
|
Loading…
Reference in New Issue