Error Message useless
Nick Sabalausky
a at a.a
Fri May 9 23:12:25 PDT 2008
"Tower Ty" <towerty at msn.com.au> wrote in message
news:g038l7$230k$1 at digitalmars.com...
> Jarrett Billingsley Wrote:
>
>> "Tower Ty" <tytower at hotmail.com.au> wrote in message
>> news:g02qih$16tn$1 at digitalmars.com...
>> > tango.core.Exception.IllegalArgumentException: Argument not valid
>> >
>> > This message from the compiler is just bloody useless
>> > Where do you go in a 200 line program?
>> >
>> > All I can see is go to each line that might be a cause and comment it
>> > out
>> > ,try to compile it again and if no good do the next one .
>> >
>> > Some lines just can't be done anyway .
>> >
>> > How hard could it be for you experts to add some detail to the error
>> > huh
>> > ??
>>
>> Is this a *compiler* error? Are you *sure*?
>>
>> Do you get the error when you compile the program or when you run it?
>>
>>
> No of course it is a run time error and I'm still looking for it , Jarrett
> sorry
Yea, that's kind of a problem with getting uncaught exceptions in the
abscence of the stack traces that reflection allows. Be glad it's such a
small program.
What I recommend doing is either step through it in a debugger (if you have
one set up), or use debugging output statements.
If you're not familiar with the trick of debugging output statements, it's
like this: Start with main() and sprinkle normal output statements through
it. For instance, if your main() is like this:
void main()
{
someFunc();
if(something)
doSomething();
anotherFunc();
yetAnotherFunc();
}
Then do this:
void main()
{
Stdout("1").newline;
someFunc();
Stdout("2").newline;
if(something)
{
Stdout("3").newline;
doSomething();
Stdout("4").newline;
}
Stdout("5").newline;
anotherFunc();
Stdout("6").newline;
yetAnotherFunc();
Stdout("7").newline;
}
Obviously, copy/paste helps there ;) Run that and you'll get something like:
1
2
5
tango.core.Exception.IllegalArgumentException: Argument not valid
In this case, we know the if() ended up false and "doSomething()" was
skipped, and we also know the exception was thrown somewhere in
"anotherFunc()". So rip those "Stdout's" out of there, and do the same thing
in "anotherFunc()". Keep drilling down like that until you find the problem.
I do that all the time in my own code (because so far I've been too lazy to
actually get a debugger set up with D :) ).
More information about the Digitalmars-d
mailing list