Exception handling idioms

Tim Bates <>
Thu Aug 25 12:02:51 CEST 2005


Hi folks,
I have a gen_server process, which if an error occurs inside it due to 
bad input I want to force the caller to crash. I find myself doing this 
a lot:

insert(Pid, Value) ->
   link(Pid),
   gen_server:call(Pid, {insert, Value}),
   unlink(Pid),
   ok.

Is this a common idiom? Is it a reasonable thing to do? It has the 
downside that the server crashes too, which is reasonable in some cases 
and somewhat unnecessary in others. How else might I do this?

Also, somewhat offtopic for this post, does anyone know of any 
fixed-point-arithmetic or manipulating-binaries-as-strings libraries in 
Erlang? Both of these would come in handy for this project.

Tim.

-- 
Tim Bates




More information about the erlang-questions mailing list