Richard Carlsson richardc@REDACTED
Tue Oct 21 21:33:22 CEST 2003

----- Original Message ----- 
From: "Sean Hinde" <sean.hinde@REDACTED>
To: "Richard Carlsson" <richardc@REDACTED>
Cc: "Erlang Questions" <erlang-questions@REDACTED>
Sent: Tuesday, October 21, 2003 9:15 PM
Subject: Re: Try/Cond

> So this is the same as:
> case catch scan(Fd) of
> foo -> ...;
> bar -> ...;
> {throw, eof} ->
> ....;
> Else -> exit(Else)
> end.
> or am I missing something more subtle?

Yes, with this "simulated try", you can't be sure that the
term {throw, eof} was not just a value returned from the
expression in the "catch", and more importantly, when you
call "exit(Else)", you exchange the caught exception for
a completely new one - often with different properties.

For example, catching a "badmatch" error and re-throwing
it with "exit" would change the exception so that it is not
logged. Another possible mistake is catching a term originally
thrown with "throw(X)" and re-throwing it using "exit(X)".

To put it short: Erlang exceptions carry more information
than most people think, and the old "catch" just wasn't
constructed with this in mind - it destroys most distinctions.
(One could say that it presents a very simple model to
the user, by lying about the details.)


More information about the erlang-questions mailing list