We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Exception freezes sketch, how to continue instead
Page Index Toggle Pages: 1
Exception freezes sketch, how to continue instead? (Read 179 times)
Exception freezes sketch, how to continue instead?
Nov 22nd, 2008, 4:53pm
 

My program reacts to music, using the values from that I make boxes etc, occasionally the value becomes too high or low and the box() line crashes.
Ie:

try {
  box(boxSize+spectrumVAR*2, boxSize, boxSize);
}
catch(Exception e)
{
  System.out.println("box crashed "+e.getMessage());
}

which says: "box crashed -2147482849
" which is actually an indexArrayOutOfBounds exception.

My question is how do I limp on past this? It makes my entire sketch freeze when id rather it just didnt make that one box?
Im not sure why the value is so obscure or even negative (-2147482849) but then some mad stuff is happeing, ideally it would catch the  exception and continue as opposed
to freezing up my sketch altogether. I could add a check for insane values of course but this keeps cropping up all over my source when I try different tunes at different volumes etc, so initially,
catchign and continuing is preferred, atleast until release.

Any ideas??
Re: Exception freezes sketch, how to continue inst
Reply #1 - Nov 22nd, 2008, 5:49pm
 
no idea about the rest of it (need to see more code) but this will be a bit clearer:

println("box crashed " + e);

and this will print out the sizes:

println("Size: " + (boxSize + spectrumVAR * 2) + ", " + boxSize + ", " + boxSize);

and maybe this:

e.printStackTrace();

find out what array it's trying to access (if indeed it is, box doesn't involve arrays as far as i can see) and what index it's trying to use.
Re: Exception freezes sketch, how to continue inst
Reply #2 - Nov 22nd, 2008, 5:50pm
 
Also sometimes the sketch just freezes, and I see no error message at all????
Page Index Toggle Pages: 1