[erlang-questions] Line numbers in escript errors?

Danil Zagoskin <>
Tue Jul 16 13:01:57 CEST 2019


Hi!

Do you use compile mode?
It gives much more meaningful stacktraces (especially when you specify
module name as well):

$ cat hello.escript
#!/usr/bin/env escript
-module(hello).
-mode(compile).

main(_) ->
  [1/X || X <- lists:seq(-5, 2)].


$ ./hello.escript
escript: exception error: an error occurred when evaluating an arithmetic
expression
  in function  hello:'-main/1-lc$^0/1-0-'/1 (./hello.escript, line 6)
  in call from hello:'-main/1-lc$^0/1-0-'/1 (./hello.escript, line 6)
  in call from escript:run/2 (escript.erl, line 758)
  in call from escript:start/1 (escript.erl, line 277)
  in call from init:start_em/1
  in call from init:do_boot/3

On Tue, Jul 16, 2019 at 1:38 PM Roger Lipscombe <>
wrote:

> When something goes wrong in my escript, I get something like this:
>
> escript: exception error: no match of right hand side value
>                  {ok, ...}
>   in function  erl_eval:expr/5 (erl_eval.erl, line 453)
>   in call from erl_eval:exprs/5 (erl_eval.erl, line 126)
>   in call from lists:foldl/3 (lists.erl, line 1263)
>
> ...but it doesn't tell me which line in my script was at fault. Is
> there a way to get escript to divulge that information?
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>


-- 
Danil Zagoskin | 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190716/7389c53a/attachment.html>


More information about the erlang-questions mailing list