commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r731781 - in /commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml: env/javascript/JSEvaluator.java io/SCXMLParser.java io/SCXMLSerializer.java model/Assign.java
Date Tue, 06 Jan 2009 00:14:01 GMT
Author: sebb
Date: Mon Jan  5 16:14:00 2009
New Revision: 731781

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

Modified:
    commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/env/javascript/JSEvaluator.java
    commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java
    commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
    commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Assign.java

Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/env/javascript/JSEvaluator.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/env/javascript/JSEvaluator.java?rev=731781&r1=731780&r2=731781&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/env/javascript/JSEvaluator.java
(original)
+++ commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/env/javascript/JSEvaluator.java
Mon Jan  5 16:14:00 2009
@@ -25,6 +25,7 @@
 import javax.script.ScriptContext;
 import javax.script.ScriptEngine;
 import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
 
 import org.apache.commons.scxml.Builtin;
 import org.apache.commons.scxml.Context;
@@ -126,7 +127,7 @@
             // ... evaluate
 
             return engine.eval(buffer.toString(),new JSBindings(context,bindings));
-        } catch (Throwable x) {
+        } catch (ScriptException x) {
             throw new SCXMLExpressionException("Error evaluating ['" + expression + "'] "
+ x);
         }
     }
@@ -192,7 +193,7 @@
             // ... evaluate
 
             return (Node) engine.eval(buffer.toString(),new JSBindings(context,bindings));
-        } catch (Throwable x) {
+        } catch (ScriptException x) {
             throw new SCXMLExpressionException("Error evaluating ['" + expression + "'] "
+ x);
         }
     }

Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java?rev=731781&r1=731780&r2=731781&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java
(original)
+++ commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java
Mon Jan  5 16:14:00 2009
@@ -24,6 +24,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;
@@ -1398,16 +1399,29 @@
                         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)
          */
         @Override

Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java?rev=731781&r1=731780&r2=731781&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
(original)
+++ commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
Mon Jan  5 16:14:00 2009
@@ -26,8 +26,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;
 
@@ -637,7 +639,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/branches/J6/src/main/java/org/apache/commons/scxml/model/Assign.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Assign.java?rev=731781&r1=731780&r2=731781&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Assign.java
(original)
+++ commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Assign.java
Mon Jan  5 16:14:00 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
@@ -268,10 +272,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 e) {
+            logError(e);
+        } catch (IOException e) {
+            logError(e);
+        } catch (ParserConfigurationException e) {
+            logError(e);
         }
         if (doc == null) {
             return null;
@@ -279,4 +287,13 @@
         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