[erlang-questions] Programming question

Samuel Rivas <>
Fri Jan 26 09:39:06 CET 2007

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.


More information about the erlang-questions mailing list