6
votes

I am just starting with Erlang, so there's nothing complex in my code yet. Often I do mistakes which lead to runtime errors.

The issue is I always see things like this:

{"init terminating in do_boot",{undef,[{'lexer_app.beam',start,[],[]},{init,start_it,1,[]},{init,start_em,1,[]}]}}

Crash dump is being written to: erl_crash.dump...done init terminating in do_boot ()

Which hardly gives me quick information on what went wrong.

Thus, I wonder, is the only way to debug the errors like this to look into erl_crash.dump, which is, frankly, looks like total abrakadabra and I need to somehow figure out even simple stupid errors by looking into it?

The main questions, is it possible to get more human-friendly errors, like "5:6 Person variable of type string is not assignable to type number"?

What's the usual workflow of debugging the app?

2
here you can read the beginning of the message: the init of the VM stops in do_boot because it has found a call to an undefined function: 'lexer_app.beam':start. I guess you have started erl with "erl -s lexer_app.beam" instead of "erl -s lexer_app", with eventually the option to add the path to the beam file "erl -s lexer_app -pa path/to/beam"Pascal

2 Answers

3
votes

You're not expected to be able to simply read the text of a crashdump file. Rather, you should be using the crashdump viewer, which is a graphical application that lets you view in a human-friendly manner all the information details a crashdump file contains.

3
votes

If you just want to see pretty comnsole error message, you can do a little trick

7> {_type, {Reason, Stack}} = {"init terminating in do_boot",{undef,[{'lexer_app.beam',start,[],[]},{init,start_it,1,[]},{init,start_em,1,[]}]}}.
{"init terminating in do_boot",
 {undef,[{'lexer_app.beam',start,[],[]},
         {init,start_it,1,[]},
         {init,start_em,1,[]}]}}
8> erlang:raise(exit, Reason, Stack).
** exception exit: undef                                         
     in function  'lexer_app.beam':start/0
        called as 'lexer_app.beam':start()
     in call from init:start_it/1 
     in call from init:start_em/1