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 › Can I throw exceptions
Page Index Toggle Pages: 1
Can I throw exceptions? (Read 606 times)
Can I throw exceptions?
Apr 2nd, 2010, 4:08am
 
Hi,

Is there any exception mechanism in processing available? I can't find it in the manual, but maybe there's a way to use them?

cheers
Re: Can I throw exceptions?
Reply #1 - Apr 2nd, 2010, 4:25am
 
Yes.

See try() and catch().

Here is an example :

Quote:
void setup() {
  try {
    myMethod();
  } catch (Exception e) {
    println(e.getMessage());
  }
}

void myMethod() throws Exception {
  println("my method");
  throw new Exception("An error occured");
}
Page Index Toggle Pages: 1