- let alreadyHandled = panic (show cli_mode ++
- " should already have been handled")
- case cli_mode of
- ShowUsage -> showGhcUsage dflags3 cli_mode
- PrintLibdir -> putStrLn (topDir dflags3)
- ShowSupportedLanguages -> alreadyHandled
- ShowVersion -> alreadyHandled
- ShowNumVersion -> alreadyHandled
- ShowInterface f -> doShowIface dflags3 f
- DoMake -> doMake session srcs
- DoMkDependHS -> doMkDependHS session (map fst srcs)
- StopBefore p -> oneShot hsc_env p srcs
- DoInteractive -> interactiveUI session srcs Nothing
- DoEval exprs -> interactiveUI session srcs $ Just $ reverse exprs
-
- dumpFinalStats dflags3
- exitWith ExitSuccess
+ handleSourceError (\e -> do
+ GHC.printExceptionAndWarnings e
+ liftIO $ exitWith (ExitFailure 1)) $ do
+ case cli_mode of
+ PrintLibdir -> liftIO $ putStrLn (topDir dflags3)
+ ShowInterface f -> liftIO $ doShowIface dflags3 f
+ DoMake -> doMake srcs
+ DoMkDependHS -> doMkDependHS (map fst srcs)
+ StopBefore p -> oneShot hsc_env p srcs >> GHC.printWarnings
+ DoInteractive -> interactiveUI srcs Nothing
+ DoEval exprs -> interactiveUI srcs $ Just $ reverse exprs
+
+ liftIO $ dumpFinalStats dflags3
+ liftIO $ exitWith ExitSuccess