[erlang-questions] Unexpected try/catch behaviour

Ulf Wiger ulf.wiger@REDACTED
Tue Feb 23 12:28:56 CET 2010


Jeroen Koops wrote:
> 
> But this:
> 
> try true of
>     true -> throw(my_error)
> catch
>     throw:What -> { error, What }
> end.
> 
> does not catch the exception and gives me, from the shell: ** exception
> throw: my_error
> 
> Is that logical in a way I don't see?

 From the Erlang Reference Manual:

"try Exprs of
     Pattern1 [when GuardSeq1] ->
         Body1;
     ...;
     PatternN [when GuardSeqN] ->
         BodyN
catch
     [Class1:]ExceptionPattern1 [when ExceptionGuardSeq1] ->
         ExceptionBody1;
     ...;
     [ClassN:]ExceptionPatternN [when ExceptionGuardSeqN] ->
         ExceptionBodyN
end
...

An exception occurring during the evaluation of Body is not caught."


BR,
Ulf W
-- 
Ulf Wiger
CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd
http://www.erlang-solutions.com
---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com



More information about the erlang-questions mailing list