exceptions

Simon Marlow simonmar@microsoft.com
Wed, 30 Jul 2003 13:40:29 +0100


=20
> just out of curiosity, which is the proper idiom?
>=20
> trace a  =3D r <- catch a (\e -> putStr "exceptional\n" >> throw e)
> trace a  =3D r <- catch a (\e -> putStr "exceptional\n" >> ioError e)
>=20
> I am worried that one might subtly change the semantics of an=20
> execption
> depending on how it was originally thrown... but i am uncertain how.
> probably some obscure case involving bottoms. But to be on the safe
> side, thought I'd ask.

The second is more correct, if you're using Prelude.catch.  If you're
using Control.Exception.catch, then you want throwIO instead of ioError.

The difference between throw and ioError is this:

  seq (throw e)   E  =3D=3D  throw e
  seq (ioError e) E  =3D=3D  E

Cheers,
	Simon