[erlang-questions] Old school exceptions vs. new age one

Jachym Holecek <>
Mon Apr 28 15:12:26 CEST 2008

On Mon, 28 Apr 2008 14:27:27 +0200, Maxim Treskin <>  
> 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.

Now if 'foo()' evaluates to {'EXIT', whatever} without throwing an  
our 'case' will still take the error-treatment branch which is not quite
what we wanted...

         -- Jachym

More information about the erlang-questions mailing list