Related to issue 21596: Shows message when fails.
authorDavid Miguelez <david.miguelez@openbravo.com>
Tue, 18 Sep 2012 16:50:46 +0200
changeset 17975 af32d2655e73
parent 17974 292bdf82cd53
child 17976 6239626a1593
Related to issue 21596: Shows message when fails.
src/org/openbravo/common/actionhandler/RMInOutPickEditLines.java
src/org/openbravo/common/actionhandler/RMShipmentPickEditLines.java
--- a/src/org/openbravo/common/actionhandler/RMInOutPickEditLines.java	Thu Sep 13 19:27:19 2012 +0200
+++ b/src/org/openbravo/common/actionhandler/RMInOutPickEditLines.java	Tue Sep 18 16:50:46 2012 +0200
@@ -27,15 +27,19 @@
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.openbravo.base.provider.OBProvider;
+import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.client.application.process.BaseProcessActionHandler;
+import org.openbravo.client.kernel.RequestContext;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBDao;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
 import org.openbravo.model.common.enterprise.Locator;
 import org.openbravo.model.common.order.OrderLine;
 import org.openbravo.model.materialmgmt.transaction.ShipmentInOut;
 import org.openbravo.model.materialmgmt.transaction.ShipmentInOutLine;
 import org.openbravo.model.sales.ConditionGoods;
+import org.openbravo.service.db.DbUtility;
 
 /**
  * 
@@ -66,6 +70,21 @@
 
     } catch (Exception e) {
       log.error(e.getMessage(), e);
+      VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
+
+      try {
+        jsonRequest = new JSONObject();
+        Throwable ex = DbUtility.getUnderlyingSQLException(e);
+        String message = OBMessageUtils.translateError(ex.getMessage()).getMessage();
+        JSONObject errorMessage = new JSONObject();
+        errorMessage.put("severity", "error");
+        errorMessage.put("text", message);
+        jsonRequest.put("message", errorMessage);
+
+      } catch (Exception e2) {
+        log.error(e.getMessage(), e2);
+        // do nothing, give up
+      }
     } finally {
       OBContext.restorePreviousMode();
     }
--- a/src/org/openbravo/common/actionhandler/RMShipmentPickEditLines.java	Thu Sep 13 19:27:19 2012 +0200
+++ b/src/org/openbravo/common/actionhandler/RMShipmentPickEditLines.java	Tue Sep 18 16:50:46 2012 +0200
@@ -28,14 +28,18 @@
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.openbravo.base.provider.OBProvider;
+import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.client.application.process.BaseProcessActionHandler;
+import org.openbravo.client.kernel.RequestContext;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBDao;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
 import org.openbravo.model.common.enterprise.Locator;
 import org.openbravo.model.common.order.OrderLine;
 import org.openbravo.model.materialmgmt.transaction.ShipmentInOut;
 import org.openbravo.model.materialmgmt.transaction.ShipmentInOutLine;
+import org.openbravo.service.db.DbUtility;
 
 /**
  * 
@@ -67,6 +71,21 @@
 
     } catch (Exception e) {
       log.error(e.getMessage(), e);
+      VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
+
+      try {
+        jsonRequest = new JSONObject();
+        Throwable ex = DbUtility.getUnderlyingSQLException(e);
+        String message = OBMessageUtils.translateError(ex.getMessage()).getMessage();
+        JSONObject errorMessage = new JSONObject();
+        errorMessage.put("severity", "error");
+        errorMessage.put("text", message);
+        jsonRequest.put("message", errorMessage);
+
+      } catch (Exception e2) {
+        log.error(e.getMessage(), e2);
+        // do nothing, give up
+      }
     } finally {
       OBContext.restorePreviousMode();
     }