Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to debug Erlang code?
    text
    copied!<p>I have some Ruby and Java background and I'm accustomed to having exact numbers of lines in the error logs. </p> <p>So, if there is an error in the compiled code, I will see the number of line which caused the exception in the console output.</p> <p>Like in this Ruby example:</p> <pre><code>my_ruby_code.rb:13:in `/': divided by 0 (ZeroDivisionError) from my_ruby_code.rb:13 </code></pre> <p>It's simple and fast - I just go to the line number 13 and fix the error.</p> <p>On the contrary, Erlang just says something like:</p> <pre><code>** exception error: no match of right hand side value [xxxx] in function my_module:my_fun/1 in call from my_module:other_fun/2 </code></pre> <p>There are no line numbers to look at. </p> <p>And if I have two lines like</p> <pre><code>X = Param1, Y = Param2, </code></pre> <p>in 'my_fun', how can understand in which line the problem lies? </p> <p>Additionally, I have tried to switch to Emacs+Elang-mode from Vim, but the only bonus I've got so far is the ability to cycle through compilation errors inside Emacs (C-k `).</p> <p>So, the process of writing code and seeking for simple logical errors like 'no match of right hand side' seems to be a bit cumbersome.</p> <p>I have tried to add a lot of "io:format" lines in the code, but it is additional work which takes time.</p> <p>I have also tried to use <a href="http://bc.tech.coop/blog/070528.html" rel="noreferrer">distel</a>, but it requires 10 steps to just open a debugger once.</p> <p>Questions:</p> <ol> <li>What is the most straight and simple way to debug Erlang code?</li> <li>Does Emacs' erlang-mode has something superior in terms of Erlang development comparing to Vim?</li> <li>What development 'write-compile-debug' cycle do you prefer? Do you leave Emacs to compile and run the code in the terminal? How do you search for errors in your Erlang code? </li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload