Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to figure out what caused a runtime error in Erlang?

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?

like image 264
Sergei Basharov Avatar asked Jul 17 '16 12:07

Sergei Basharov


People also ask

Which block can be used to handle runtime errors?

To handle a runtime error, the code can be placed within a try-catch block and the error can be caught inside the catch block.

How do I show Erlang call stack?

stacktop([Top|_]) -> Top. ancestor(N) -> {_,Stacktrace}=erlang:process_info(self(),current_stacktrace), ancestor(N+1,Stacktrace). ancestor(1,S) -> format_stack_entry(stacktop(S)); ancestor(N,[_|T]) -> ancestor(N-1,T).

What is runtime error in C#?

A runtime error in a program is an error that occurs while the program is running after being successfully compiled. Runtime errors are commonly called referred to as “bugs” and are often found during the debugging process before the software is released.

What are error handling functions in C?

Error handling is not supported by C language. There are some other ways by which error handling can be done in C language. The header file “error. h” is used to print the errors using return statement function. It returns -1 or NULL in case of any error and errno variable is set with the error code.


2 Answers

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.

like image 72
Steve Vinoski Avatar answered Nov 15 '22 08:11

Steve Vinoski


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 
like image 38
Lol4t0 Avatar answered Nov 15 '22 09:11

Lol4t0