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 › Catching a RuntimeException thrown by proXML
Page Index Toggle Pages: 1
Catching a RuntimeException thrown by proXML (Read 382 times)
Catching a RuntimeException thrown by proXML
May 8th, 2006, 9:29pm
 
I'm using proXML to gather dynamic data from a php script, but every once in a while the server fails to generate the result or is unavailable (flakey network?). But in any case when I try to load data at this time, a RuntimeException is thrown by this code in proXML:

   try {
     URL url = new URL(filename);
     stream = url.openStream();
     return stream;

   } catch (MalformedURLException e) {
     // not a url, that's fine

   } catch (IOException e) {
     throw new RuntimeException("Error downloading from URL " + filename);
   }

The problem is that I cannot seem to catch this exception in my applet using:

   try
   {
     XMLInOut xml_data_loader = new XMLInOut( my_applet );
     String[] xml_file_path = xml_data_path.split("/");
     xml_data = xml_data_loader.loadElementFrom( "http://wwwtest.loni.ucla.edu/cluster_activity/check.php?mode=xml&file="+xml_file_path[xml_file_path.length-1] );
   }
   catch(RuntimeException r)
   {
     println("RuntimeException!");
     return;
   }

Is it necessary for proXML to throw a runtime exception? But in any case I'm not sure why that exception isn't caught.
Re: Catching a RuntimeException thrown by proXML
Reply #1 - May 8th, 2006, 9:54pm
 
did you try to just catch the generic exception?

try {

...

} catch ( Exception e ) {
  e.printStackTrace();
}

just a thought ..
F
Re: Catching a RuntimeException thrown by proXML
Reply #2 - May 8th, 2006, 11:32pm
 
I just tried it but unfortunately it still wasn't caught. I'm not sure how this exception skips through the try block to reach the runtime environment.
Page Index Toggle Pages: 1