[erlang-questions] Handling unexpected messages (was Re: Erlang shell crashes)

Ben Butler-Cole <>
Mon Oct 30 11:50:32 CET 2006

Jay Nelson said:

> You should also use a catch all message to remove any messages you were not expecting:
> receive
>   {From, expected_msg, Data} ->
>         do_something(Data);
>   AnyUnexpectedMsg ->
>         log_and_skip_handling(AnyUnexpectedMsg)
> end.

I'm writing my first Erlang system and need to decide general policies for this kind of thing. Is there not an argument for exiting if you get an unexpected message rather than just ignoring it? I suppose that opens you up to a denial of service attack if your Pids or process names aren't completely secure.

What is the standard way of dealing with this?


More information about the erlang-questions mailing list