@@ -10,7 +10,7 @@ where
1010
1111import Control.Exception
1212import Data.Text (Text)
13−import System.Exit (exitFailure)
13+import System.Exit (ExitCode (ExitFailure), exitWith)
1414import System.IO
1515import qualified GHC
1616import qualified Outputable as GHC
@@ -53,7 +53,13 @@ withPrettyOrmoluExceptions m = m `catch` h
5353 h :: OrmoluException -> IO a
5454 h e = do
5555 hPutStrLn stderr (displayException e)
56− exitFailure
56+ exitWith . ExitFailure $
57+ case e of
58+ -- Error code 1 is for `error` or `notImplemented`
59+ OrmoluCppEnabled -> 2
60+ OrmoluParsingFailed _ _ -> 3
61+ OrmoluOutputParsingFailed _ _ -> 4
62+ OrmoluASTDiffers _ _ -> 5
5763
5864----------------------------------------------------------------------------
5965-- Helpers