If I write some erlang code to build an observation tree, and then run the application upon loading with the following command, it can be very difficult to find out why this does not work:
erl -s myapp -pa ebin ... ...
(myapp example module)
-module(myapp). -export([start/0]). start() -> application:start(myapp).
Say my application launches the myapp_sup dispatcher. myapp_sup, in turn, runs several supervisors (say server_sup, database_sup, another_sup).
These executives launched some gen_servers.
At some point, if there is an error in my code, I cannot find it!
I wrote a call to somemodule: functionthatdoesntexists () in the init callback of some gen_server.
All vm say that "init exits in boot" and then displays the location of the badmatch error, specifying the file and line of my top module (myapp).
(Badmatch, because ok = application: start (...) will not match).
I look in the erl_crash.dump file and there is no information about this function undefined (until I find it in the list of atoms).
So, I wrote some journal to see an example where the error is, but then I will have to run my gen_servers manually to return the correct error information.
What am I missing, how can I understand this faster?
thanks