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 › dealing with errors
Page Index Toggle Pages: 1
dealing with errors (Read 377 times)
dealing with errors
Sep 29th, 2008, 5:32am
 
hello,

I would to ask if Processing has some kind of error processing, or if most errors are going to generate Java exceptions. I am using some data from Internet, and my application crashes when it cann't access my server. I would like to test if it can acess the server and, if not, use the last data grabbed from it. But I don't see any elegant way to make that, despite programming directly in Java.

thank you,
andrei
Re: dealing with errors
Reply #1 - Sep 29th, 2008, 10:16pm
 
What do you call "crashes"? In traditional programming (eg. in C), it means the system is displaying an error message after the program exited (with flames and thunder). In Java, it is more likely to display some stack trace, no?

In Java, the traditional way to handle such issue (like resource not available) is to wrap the possibly offending call in a try/catch block: it offers an opportunity to recover from the error.
Re: dealing with errors
Reply #2 - Sep 30th, 2008, 2:33pm
 
hello Phillo,

I call "crash" when Processing stops due to an exception. I would like to have some kind of try/catch with Processing. I tried, but was not able to find any information about this.

thank you,
andrei
Re: dealing with errors
Reply #3 - Sep 30th, 2008, 2:57pm
 
we don't do exceptions from (nearly) any processing api, see the explanation here:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=LibraryProblems;action=display;num=1221502447;start=4#4

if you're doing something like loadStrings() or loadImage(), it will return null when it fails. if you're using the net client class, see the explanation in that thread.
Re: dealing with errors
Reply #4 - Sep 30th, 2008, 3:16pm
 
thanks for the link. I am using processing.xml.XMLElement class to read a XML dinamically generated at a server by a PHP script, but I was not being able to deal with lost connections or with the server being down. After reading the link, I think I should study the source of XMLElement class Smiley
Page Index Toggle Pages: 1