[erlang-questions] dialyzer is driving me nuts

Ulf Wiger ulf.wiger@REDACTED
Wed Oct 19 13:02:18 CEST 2011

On 19 Oct 2011, at 12:57, Jesper Louis Andersen wrote:

> On Wed, Oct 19, 2011 at 11:03, Tim Watson <watson.timothy@REDACTED> wrote:
>>> The problem of the catch-all clause in gen_servers, etc. is a generic one.
>> Do gen_servers really need a catch-all clause? Can't they just be left to
>> crash? I don't mean to be isolent, I'm just wondering.
> You are right that you can skip a catch-all clause, but it will lead
> to crashes left and right as soon as a process gets sent something
> which is a little off. I tend to lace my catch-all clauses with an
> error_logger message so I know something bad was sent.

I tend to wrap gen_server:call() in order to raise the exception in the client:

call(Server, Req) ->
   case gen_server:call(Server, Req) of
      badarg ->
      Reply ->


handle_call(_Unknown, _From, S) ->
   {reply, badarg, S}.

Obviously, the scheme can be extended to carry some more information for the client-side exception.

Ulf W

Ulf Wiger, CTO, Erlang Solutions, Ltd.

More information about the erlang-questions mailing list