commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r731791 - in /commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml: io/SCXMLDigester.java io/SCXMLParser.java io/SCXMLSerializer.java model/Assign.java
Date Tue, 06 Jan 2009 00:31:39 GMT
Author: sebb
Date: Mon Jan  5 16:31:38 2009
New Revision: 731791

URL: http://svn.apache.org/viewvc?rev=731791&view=rev
Log:
SCXML-103 Remove any catch (Throwable t) occurences:
Catch specific Exceptions/Errors rather than generic ones

Modified:
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java?rev=731791&r1=731790&r2=731791&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
(original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
Mon Jan  5 16:31:38 2009
@@ -25,6 +25,7 @@
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.commons.digester.Digester;
@@ -1325,16 +1326,28 @@
                         newInstance();
                     DocumentBuilder db = dbFactory.newDocumentBuilder();
                     attrNode = db.parse(path);
-                } catch (Throwable t) { // you read that correctly
-                    org.apache.commons.logging.Log log = LogFactory.
-                        getLog(SCXMLDigester.class);
-                    log.error(t.getMessage(), t);
+                } catch (FactoryConfigurationError t) {
+                    logError(t);
+                } catch (ParserConfigurationException t) {
+                    logError(t);
+                } catch (SAXException t) {
+                    logError(t);
+                } catch (IOException t) {
+                    logError(t);
                 }
                 return;
             }
         }
 
         /**
+         * @param throwable
+         */
+        private void logError(Throwable throwable) {
+            org.apache.commons.logging.Log log = LogFactory.getLog(SCXMLDigester.class);
+            log.error(throwable.getMessage(), throwable);
+        }
+
+        /**
          * @see Rule#end(String, String)
          */
         public final void end(final String namespace, final String name) {

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java?rev=731791&r1=731790&r2=731791&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java
(original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java
Mon Jan  5 16:31:38 2009
@@ -25,6 +25,7 @@
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.commons.digester.Digester;
@@ -1387,16 +1388,28 @@
                         newInstance();
                     DocumentBuilder db = dbFactory.newDocumentBuilder();
                     attrNode = db.parse(path);
-                } catch (Throwable t) { // you read that correctly
-                    org.apache.commons.logging.Log log = LogFactory.
-                        getLog(SCXMLParser.class);
-                    log.error(t.getMessage(), t);
+                } catch (FactoryConfigurationError t) {
+                    logError(t);
+                } catch (ParserConfigurationException t) {
+                    logError(t);
+                } catch (SAXException t) {
+                    logError(t);
+                } catch (IOException t) {
+                    logError(t);
                 }
                 return;
             }
         }
 
         /**
+         * @param throwable
+         */
+        private void logError(Throwable throwable) {
+            org.apache.commons.logging.Log log = LogFactory.getLog(SCXMLParser.class);
+            log.error(throwable.getMessage(), throwable);
+        }
+
+        /**
          * @see Rule#end(String, String)
          */
         public final void end(final String namespace, final String name) {

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java?rev=731791&r1=731790&r2=731791&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
(original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
Mon Jan  5 16:31:38 2009
@@ -27,8 +27,10 @@
 import javax.xml.transform.Result;
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
@@ -650,7 +652,9 @@
             TransformerFactory tfFactory = TransformerFactory.newInstance();
             transformer = tfFactory.newTransformer();
             transformer.setOutputProperties(outputProps);
-        } catch (Throwable t) {
+        } catch (TransformerFactoryConfigurationError t) {
+            return null;
+        } catch (TransformerConfigurationException e) {
             return null;
         }
         return transformer;

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java?rev=731791&r1=731790&r2=731791&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java Mon
Jan  5 16:31:38 2009
@@ -16,9 +16,12 @@
  */
 package org.apache.commons.scxml.model;
 
+import java.io.IOException;
 import java.util.Collection;
 
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -34,6 +37,7 @@
 import org.apache.commons.scxml.semantics.ErrorConstants;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
 
 /**
  * The class in this SCXML object model that corresponds to the
@@ -267,10 +271,14 @@
         try {
             doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().
                 parse(resolvedSrc);
-        } catch (Throwable t) {
-            org.apache.commons.logging.Log log = LogFactory.
-                getLog(Assign.class);
-            log.error(t.getMessage(), t);
+        } catch (FactoryConfigurationError t) {
+            logError(t);
+        } catch (SAXException t) {
+            logError(t);
+        } catch (IOException t) {
+            logError(t);
+        } catch (ParserConfigurationException t) {
+            logError(t);
         }
         if (doc == null) {
             return null;
@@ -278,4 +286,12 @@
         return doc.getDocumentElement();
     }
 
+    /**
+     * @param throwable
+     */
+    private void logError(Throwable throwable) {
+        org.apache.commons.logging.Log log = LogFactory.getLog(Assign.class);
+        log.error(throwable.getMessage(), throwable);
+    }
+
 }



Mime
View raw message