[erlang-questions] Old school exceptions vs. new age one
Jachym Holecek
jachym.holecek@REDACTED
Mon Apr 28 15:12:26 CEST 2008
On Mon, 28 Apr 2008 14:27:27 +0200, Maxim Treskin <zerthurd@REDACTED>
wrote:
> Can you say me, why is new-style better than old?
The 'try ... [of ...] catch ... end' construct is more general and makes it
clear whether or not an exception occured. With just 'catch' consider:
case catch foo() of
{'EXIT', Reason} ->
%% Exception occured.
...;
Result ->
%% All is fine.
...
end.
Now if 'foo()' evaluates to {'EXIT', whatever} without throwing an
exception,
our 'case' will still take the error-treatment branch which is not quite
what we wanted...
HTH,
-- Jachym
More information about the erlang-questions
mailing list