Ignoring ExitExceptions

Tim Jolly jolly@compuserve.com
Mon, 21 Jul 2003 18:38:41 +0100


I'm looking for a way to return an arbitrary exit code to the OS.  The
standard `exitWith' function does the job, but unfortunately it also has
the side-effect of reporting an exception (I'm using GHC 6.0, with
Control.Exception imported for other purposes).

When a fatal error occurs, my program will already have issued a
meaningful error message, and the added "*** Exception: exit:
ExitFailure 2" will serve only to confuse users.  Unfortunately it
appears that the only way to return an exit code is to let an
ExitException pass unhandled.

All I'm really asking for is a way to use the exitWith function as
defined in Haskell 98, along with the exception extensions provided in
Control.Exception.  Is there perhaps some way to prevent ExitExceptions
from being reported, or a way to exclude certain types of exception from
the handling in Control.Exception?  Or can anyone suggest an alternative
approach?

-- TJ