From 4e721f189b99cbccea8756d2ead2a3e2d5fcd29b Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Thu, 15 Feb 2018 11:01:41 +0000 Subject: [PATCH] Fixed: Fix Default or Empty Catch block in Java and Groovy files (OFBIZ-8341) Fixes few remaining swallowed Exception in Groovy files. Not sure if always showing an error message in ui is a good idea. But this should not happen too often and could help users to fix wrong passed numbers... git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1824294 13f79535-47bb-0310-9956-ffa450edef68 --- .../facility/CountFacilityInventoryByProduct.groovy | 9 ++++++--- .../facility/ViewFacilityInventoryByProduct.groovy | 3 ++- .../shipment/ReceiveInventoryAgainstPurchaseOrder.groovy | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/applications/product/groovyScripts/facility/facility/CountFacilityInventoryByProduct.groovy b/applications/product/groovyScripts/facility/facility/CountFacilityInventoryByProduct.groovy index afb2df2aef..921969e504 100644 --- a/applications/product/groovyScripts/facility/facility/CountFacilityInventoryByProduct.groovy +++ b/applications/product/groovyScripts/facility/facility/CountFacilityInventoryByProduct.groovy @@ -181,7 +181,8 @@ if (action) { checkTime = UtilDateTime.toTimestamp(cal.getTime()) searchParameterString += "&monthsInPastLimit=" + monthsInPastLimitStr } catch (Exception e) { - // Ignore + Debug.logError(e, "Caught an exception : " + e.toString(), module) + request.setAttribute("_ERROR_MESSAGE", "An exception occured please check the log") } } @@ -278,7 +279,8 @@ if (action) { try { salesUsageQuantity += salesUsageItem.getDouble("quantity").doubleValue() } catch (Exception e) { - // Ignore + Debug.logError(e, "Caught an exception : " + e.toString(), module) + request.setAttribute("_ERROR_MESSAGE", "An exception occured please check the log") } } } @@ -299,7 +301,8 @@ if (action) { try { productionUsageQuantity += productionUsageItem.getDouble("quantity").doubleValue() } catch (Exception e) { - // Ignore + Debug.logError(e, "Caught an exception : " + e.toString(), module) + request.setAttribute("_ERROR_MESSAGE", "An exception occured please check the log") } } } diff --git a/applications/product/groovyScripts/facility/facility/ViewFacilityInventoryByProduct.groovy b/applications/product/groovyScripts/facility/facility/ViewFacilityInventoryByProduct.groovy index 8de93367ca..b5a3b03de3 100644 --- a/applications/product/groovyScripts/facility/facility/ViewFacilityInventoryByProduct.groovy +++ b/applications/product/groovyScripts/facility/facility/ViewFacilityInventoryByProduct.groovy @@ -174,7 +174,8 @@ if (action) { checkTime = UtilDateTime.toTimestamp(cal.getTime()) searchParameterString += "&monthsInPastLimit=" + monthsInPastLimitStr } catch (Exception e) { - // Ignore + Debug.logError(e, "Caught an exception : " + e.toString(), module) + request.setAttribute("_ERROR_MESSAGE", "An exception occured please check the log") } } diff --git a/applications/product/groovyScripts/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.groovy b/applications/product/groovyScripts/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.groovy index bf976d1194..ea2293f175 100644 --- a/applications/product/groovyScripts/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.groovy +++ b/applications/product/groovyScripts/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.groovy @@ -216,8 +216,10 @@ if (productIdToReceive) { if (productQtyToReceive) { try { quantity = Double.parseDouble(productQtyToReceive) - } catch (Exception e) { + } catch (NumberFormatException nfe) { // Ignore the quantity update if there's a problem parsing it + Debug.logError(nfe, "Caught an exception : " + nfe.toString(), module) + request.setAttribute("_ERROR_MESSAGE", "An exception occured please check the log") } }