[erlang-questions] Nested Case Statements v.s. multiple functions

Joe Armstrong <>
Tue Sep 26 18:46:12 CEST 2017

On Tue, Sep 26, 2017 at 5:43 PM, code wiget <> wrote:
> Thank you all for your replies, I went ahead and changed my function names
> and added guards, and it now looks far cleaner.
> One thing that I keep seeing in this thread though is some variant of “crash
> early, crash often,” and this is a little troubling. What if you are writing
> a program that is receiving a messages and has a queue awaiting action? If
> the program dies, those messages will be lost, and if the calling processes
> made ‘casts’ then those messages won’t ever be delivered or processed. Also,
> it takes a bit of time for the supervisor to re-initialize the process, and
> this could be bad.
> Is it always a good idea to “crash often” when bad input is received?

You have to make your mind up. Choose between:

   + terminate the entire erlang system
   + crash the entire computer
   + terminate the process receiving the bad data
   + throw away the bad input and continue
   + crash the program that send you the bad data
   + many more things ...

This is part of the design of your application and has nothing to do
with Erlang.

Make your mind up about what you want to do if things go wrong
then write the code to do it.

Hint: write something to a log on stable storage *before* crashing
you should be able to do a post-mortem analysis of the crash.


> Thanks for all of your help!

More information about the erlang-questions mailing list