[erlang-questions] Programming question

Ulf Wiger (TN/EAB) <>
Fri Jan 26 10:01:58 CET 2007


Yes, this is one of the problems with the old
catch/throw, which were eminently documented in 
Richard Carlsson's et al paper on Erlang's Exception Handling Revisited

http://www.erlang.se/workshop/2004/exception.pdf

BR,
Ulf W

> -----Original Message-----
> From:  
> [mailto:] On Behalf Of Samuel Rivas
> Sent: den 26 januari 2007 09:39
> To: 
> Subject: Re: [erlang-questions] Programming question
> 
> Ulf Wiger wrote:
> > > - I would expect that 'throw_it' caused an exception similar
> > >    to 'expected' (with the right stack trace)
> > 
> > The exception in this case is raised by the gen_server 
> module, which 
> > expects a return value from Mod:handle_call/3 to be 
> {reply,Rep,S1} | 
> > {noreply,S1} | {stop,Reason,S1}
> > | {stop,Rep,Reason,S1}
> > 
> > 'ouch' doesn't qualify as a valid return value.
> > 
> > In the case of 'expected', your code raises an exception, which is 
> > caught by the gen_server module, which adds some info (e.g. last 
> > message) and then exits (I'm not looking at the code - 
> can't remember 
> > if it calls exit/1 or error/1.)
> > 
> > 
> > >  - I would expect that 'weird' caused a similar exception too,
> > >    but it does not even crash the server.
> > 
> > ...because gen_server uses an old-style catch, and therefore cannot 
> > tell the difference between your thrown value and a normal 
> (and legal) 
> > return value.
> 
>   I knew it, my point is that you have to read the source. 
> Otherwise the results are astonishing.
> 
>   Regards
> -- 
> 	Samuel
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list