(newbie still) error messages

Mats Cronqvist mats.cronqvist@REDACTED
Tue Jul 11 10:06:40 CEST 2006


Jon Slenk wrote:
> hi,
> 
> What habits or tools are used to understand or expand upon Erlang error 
> messages? For example, I am getting a badarg error but it does not tell 
> me exactly which argument is bad. The last thing on the stack is 
> {test,ping,2} which means test:ping/2 rather than "test:ping, argument 2 
> was bad" 

   the error message means "somewhere in test:ping/2 there was something that 
failed because of a bad argument".

> It seems to me that if I were to have to debug a problem in a 
> larger system it would be nice to know exactly where and what arg is 
> bad, but I don't see how to get such information.

   you don't see it because it's not there(*) :>. debugging large systems is 
possible because (typically) any one function has at most one thing that can 
toss a badarg (that's one reason to keep the functions small). of course, this 
only helps you once you've learnt where badargs might come from. e.g. "!" will 
exit with badarg if the first arg is not a pid or a registered name.

> Just so you know, I am getting the error on purpose while experimenting 
> / learning, since test:ping/2 takes (Count, Pong_pid) and I am calling 
> it as test:ping( 0, [] ).

   so there's probably a

Pong_pid ! Data

   in test:ping/2

   mats

* rumour has it that smart_exceptions in jungerl.sourceforge.net provides this 
functionality. i've never tried it though



More information about the erlang-questions mailing list