why is the error reason in a catch/try truncated?

Joe Armstrong <>
Tue Jan 18 15:52:15 CET 2011

I have a program.

When I run the "uncaught" version it prints a very nice error message like

> compile_file(File, Args, ParseTree).

{"init terminating in

This tells be exactly were I bombed.

In my "production" version of the code I add wrapper with a catch/try to
trap any unwanted errors.
So I write:

compile_file(File, Args, ParseTree) ->
 case (catch compile_file0(File, Args, ParseTree)) of
    {'EXIT', Why} ->
        io:format("Compile file:~s aborted with:~p ~n",[File, Why]);
    _ ->

But when i run this

> compile_file(File, Args, ParseTree).
Compile file:first.c aborted with:error badarg

So the Why in the error tuple has lost all the useful information that was
the untrapped code.

To find the error I have to comment out the wrapped version and
run the unwrapped version. This is because Why is just the atom
badarg and not the more verbose {badarg, ...}

I find this behavior very unhelpfull - am I the only one?


More information about the erlang-questions mailing list