From my perspective, a bunch of catch blocks that all do the exact same thing can be consolidated into a single catch block.

-Adrian

On 5/5/2012 9:46 PM, [email protected] wrote:
Author: jleroux
Date: Sat May  5 20:46:39 2012
New Revision: 1334497

URL: http://svn.apache.org/viewvc?rev=1334497&view=rev
Log:
Non functional changes.
Removes a bunch of useless exceptions catches. There are still few cases to 
discuss, I believe there are useless (or at least without much more 
information) as well. we will decide on dev ML later...

Modified:
     
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
     
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java
     
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsMockApiServlet.java
     
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java
     
ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/WfApplicationServices.java

Modified: 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java?rev=1334497&r1=1334496&r2=1334497&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
 (original)
+++ 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
 Sat May  5 20:46:39 2012
@@ -19,7 +19,6 @@
  package org.ofbiz.accounting.thirdparty.clearcommerce;

  import java.io.ByteArrayOutputStream;
-import java.io.IOException;
  import java.io.OutputStream;
  import java.math.BigDecimal;
  import java.util.ArrayList;
@@ -28,7 +27,6 @@ import java.util.List;
  import java.util.Locale;
  import java.util.Map;

-import javax.xml.parsers.ParserConfigurationException;
  import javax.xml.transform.TransformerException;

  import org.ofbiz.accounting.payment.PaymentGatewayServices;
@@ -47,7 +45,6 @@ import org.ofbiz.service.DispatchContext
  import org.ofbiz.service.ServiceUtil;
  import org.w3c.dom.Document;
  import org.w3c.dom.Element;
-import org.xml.sax.SAXException;


  /**
@@ -921,12 +918,8 @@ public class CCPaymentServices {
          Document responseDocument = null;
          try {
              responseDocument = UtilXml.readXmlDocument(response, false);
-        } catch (SAXException se) {
-            throw new ClearCommerceException("Error reading response Document from 
a String: " + se.getMessage());
-        } catch (ParserConfigurationException pce) {
-            throw new ClearCommerceException("Error reading response Document from 
a String: " + pce.getMessage());
-        } catch (IOException ioe) {
-            throw new ClearCommerceException("Error reading response Document from 
a String: " + ioe.getMessage());
+        } catch (Exception e) {
+            throw new ClearCommerceException("Error reading response Document from 
a String: " + e.getMessage());
          }
          if (Debug.verboseOn()) Debug.logVerbose("Result severity from 
clearCommerce:" + getMessageListMaxSev(responseDocument), module);
          if (Debug.verboseOn()&&  getMessageListMaxSev(responseDocument)>  4)

Modified: 
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java?rev=1334497&r1=1334496&r2=1334497&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java
 (original)
+++ 
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java
 Sat May  5 20:46:39 2012
@@ -19,7 +19,6 @@

  package org.ofbiz.shipment.thirdparty.fedex;

-import java.io.IOException;
  import java.io.StringWriter;
  import java.math.BigDecimal;
  import java.sql.Timestamp;
@@ -27,8 +26,6 @@ import java.util.List;
  import java.util.Locale;
  import java.util.Map;

-import javax.xml.parsers.ParserConfigurationException;
-
  import javolution.util.FastList;
  import javolution.util.FastMap;

@@ -58,7 +55,6 @@ import org.ofbiz.service.ServiceUtil;
  import org.ofbiz.shipment.shipment.ShipmentServices;
  import org.w3c.dom.Document;
  import org.w3c.dom.Element;
-import org.xml.sax.SAXException;

  /**
   * Fedex Shipment Services
@@ -364,24 +360,12 @@ public class FedexServices {
              try {
                  fDXSubscriptionReplyDocument = 
UtilXml.readXmlDocument(fDXSubscriptionReplyString, false);
                  Debug.logInfo("Fedex response for FDXSubscriptionRequest:" + 
fDXSubscriptionReplyString, module);
-            } catch (SAXException se) {
-                String errorMessage = "Error parsing the FDXSubscriptionRequest 
response: " + se.toString();
-                Debug.logError(se, errorMessage, module);
-                return 
ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                        
"FacilityShipmentFedexSubscriptionTemplateParsingError",
-                        UtilMisc.toMap("errorString", se.toString()), locale));
-            } catch (ParserConfigurationException pce) {
-                String errorMessage = "Error parsing the FDXSubscriptionRequest 
response: " + pce.toString();
-                Debug.logError(pce, errorMessage, module);
-                return 
ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                        
"FacilityShipmentFedexSubscriptionTemplateParsingError",
-                        UtilMisc.toMap("errorString", pce.toString()), 
locale));
-            } catch (IOException ioe) {
-                String errorMessage = "Error parsing the FDXSubscriptionRequest 
response: " + ioe.toString();
-                Debug.logError(ioe, errorMessage, module);
+            } catch (Exception e) {
+                String errorMessage = "Error parsing the FDXSubscriptionRequest 
response: " + e.toString();
+                Debug.logError(e, errorMessage, module);
                  return 
ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                          
"FacilityShipmentFedexSubscriptionTemplateParsingError",
-                        UtilMisc.toMap("errorString", ioe.toString()), 
locale));
+                        UtilMisc.toMap("errorString", e.toString()), locale));
              }

              Element fedexSubscriptionReplyElement = 
fDXSubscriptionReplyDocument.getDocumentElement();
@@ -996,17 +980,9 @@ public class FedexServices {
          Document fdxShipReplyDocument = null;
          try {
              fdxShipReplyDocument = 
UtilXml.readXmlDocument(fDXShipReplyString, false);
-        } catch (SAXException se) {
-            String errorMessage = "Error parsing the FDXShipReply: " + 
se.toString();
-            Debug.logError(se, errorMessage, module);
-            // TODO: Cancel the package
-        } catch (ParserConfigurationException pe) {
-            String errorMessage = "Error parsing the FDXShipReply: " + 
pe.toString();
-            Debug.logError(pe, errorMessage, module);
-            // TODO Cancel the package
-        } catch (IOException ioe) {
-            String errorMessage = "Error parsing the FDXShipReply: " + 
ioe.toString();
-            Debug.logError(ioe, errorMessage, module);
+        } catch (Exception e) {
+            String errorMessage = "Error parsing the FDXShipReply: " + 
e.toString();
+            Debug.logError(e, errorMessage, module);
              // TODO Cancel the package
          }


Modified: 
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsMockApiServlet.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsMockApiServlet.java?rev=1334497&r1=1334496&r2=1334497&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsMockApiServlet.java
 (original)
+++ 
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsMockApiServlet.java
 Sat May  5 20:46:39 2012
@@ -30,16 +30,13 @@ import javax.servlet.ServletOutputStream
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
-import javax.xml.parsers.ParserConfigurationException;
  import javax.xml.transform.TransformerException;

+import org.ofbiz.base.util.Debug;
  import org.ofbiz.base.util.UtilValidate;
  import org.ofbiz.base.util.UtilXml;
-import org.ofbiz.base.util.Debug;
-
  import org.w3c.dom.Document;
  import org.w3c.dom.Element;
-import org.xml.sax.SAXException;

  /**
   * USPS Webtools API Mock API Servlet
@@ -77,14 +74,8 @@ public class UspsMockApiServlet extends
          Document requestDocument = null;
          try {
              requestDocument = UtilXml.readXmlDocument(xmlValue, false);
-        } catch (SAXException se) {
-            Debug.logError(se, module);
-            return;
-        } catch (ParserConfigurationException pce) {
-            Debug.logError(pce, module);
-            return;
-        } catch (IOException xmlReadException) {
-            Debug.logError(xmlReadException, module);
+        } catch (Exception e) {
+            Debug.logError(e, module);
              return;
          }


Modified: 
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java?rev=1334497&r1=1334496&r2=1334497&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java
 (original)
+++ 
ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java
 Sat May  5 20:46:39 2012
@@ -32,7 +32,6 @@ import java.util.ListIterator;
  import java.util.Locale;
  import java.util.Map;

-import javax.xml.parsers.ParserConfigurationException;
  import javax.xml.transform.TransformerException;

  import javolution.util.FastList;
@@ -67,7 +66,6 @@ import org.ofbiz.shipment.shipment.Shipm
  import org.ofbiz.shipment.shipment.ShipmentWorker;
  import org.w3c.dom.Document;
  import org.w3c.dom.Element;
-import org.xml.sax.SAXException;

  /**
   * USPS Webtools API Services
@@ -1757,18 +1755,8 @@ public class UspsServices {
          Document responseDocument = null;
          try {
              responseDocument = UtilXml.readXmlDocument(responseString, false);
-        } catch (SAXException se) {
-            throw new 
UspsRequestException(UtilProperties.getMessage(resourceError,
-                    "FacilityShipmentUspsResponseError",
-                    UtilMisc.toMap("errorString", se.getMessage()), locale));
-        } catch (ParserConfigurationException pce) {
-            throw new 
UspsRequestException(UtilProperties.getMessage(resourceError,
-                    "FacilityShipmentUspsResponseError",
-                    UtilMisc.toMap("errorString", pce.getMessage()), locale));
-        } catch (IOException xmlReadException) {
-            throw new 
UspsRequestException(UtilProperties.getMessage(resourceError,
-                    "FacilityShipmentUspsResponseError",
-                    UtilMisc.toMap("errorString", 
xmlReadException.getMessage()), locale));
+        } catch (Exception e) {
+            throw new UspsRequestException(UtilProperties.getMessage(resourceError, 
"FacilityShipmentUspsResponseError", UtilMisc.toMap("errorString", 
e.getMessage()), locale));
          }

          // If a top-level error document is returned, throw exception

Modified: 
ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/WfApplicationServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/WfApplicationServices.java?rev=1334497&r1=1334496&r2=1334497&view=diff
==============================================================================
--- 
ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/WfApplicationServices.java
 (original)
+++ 
ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/WfApplicationServices.java
 Sat May  5 20:46:39 2012
@@ -25,8 +25,6 @@ import java.util.HashMap;
  import java.util.List;
  import java.util.Map;

-import javax.xml.parsers.ParserConfigurationException;
-
  import org.ofbiz.base.util.Debug;
  import org.ofbiz.base.util.GeneralException;
  import org.ofbiz.base.util.ObjectType;
@@ -41,7 +39,6 @@ import org.ofbiz.entity.serialize.XmlSer
  import org.ofbiz.service.DispatchContext;
  import org.ofbiz.service.GenericServiceException;
  import org.ofbiz.service.ModelService;
-import org.xml.sax.SAXException;

  /**
   * Workflow Application Services - 'Services' and 'Workers' for interaction 
with Workflow Application API
@@ -219,14 +216,8 @@ public class WfApplicationServices {
              throws GenericServiceException {
          try {
              return UtilGenerics.checkMap(XmlSerializer.deserialize((String) 
runTimeData.get("runtimeInfo"), delegator));
-        } catch (SerializeException se) {
-            throw new GenericServiceException(se.getMessage(), se);
-        } catch (ParserConfigurationException pe) {
-            throw new GenericServiceException(pe.getMessage(), pe);
-        } catch (SAXException se) {
-            throw new GenericServiceException(se.getMessage(), se);
-        } catch (IOException ioe) {
-            throw new GenericServiceException(ioe.getMessage(), ioe);
+        } catch (Exception e) {
+            throw new GenericServiceException(e.getMessage(), e);
          }
      }



Reply via email to