You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2015/03/05 07:20:40 UTC

stratos git commit: handling specific exceptions

Repository: stratos
Updated Branches:
  refs/heads/master d336dfbca -> ee66a9cba


handling specific exceptions


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/ee66a9cb
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/ee66a9cb
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/ee66a9cb

Branch: refs/heads/master
Commit: ee66a9cba1631079da099b4f67c9c65929f5a893
Parents: d336dfb
Author: R-Rajkumar <rr...@gmail.com>
Authored: Thu Mar 5 11:50:18 2015 +0530
Committer: R-Rajkumar <rr...@gmail.com>
Committed: Thu Mar 5 11:50:18 2015 +0530

----------------------------------------------------------------------
 .../rest/endpoint/api/StratosApiV41Utils.java   | 44 +++++++++++++++-----
 1 file changed, 33 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/ee66a9cb/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index d9a7025..3ae8ceb 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -579,13 +579,21 @@ public class StratosApiV41Utils {
 			}
 			serviceClient.addApplicationPolicy(applicationPolicy);
 		} catch (RemoteException e) {
-			throw new RestAPIException(e);
+			String msg = "Could not add application policy" + e.getLocalizedMessage();
+			log.error(msg, e);
+			throw new RestAPIException(msg);
 		} catch (AutoscalerServiceInvalidPolicyExceptionException e) {
-			throw new RestAPIException(e);
+			String msg = "Could not add application policy. Invalid policy. " + e.getLocalizedMessage();
+			log.error(msg, e);
+			throw new RestAPIException(msg);
 		} catch (AutoscalerServiceRemoteExceptionException e) {
-			throw new RestAPIException(e);
+			String msg = "Could not add application policy" + e.getLocalizedMessage();
+			log.error(msg, e);
+			throw new RestAPIException(msg);
 		} catch (AutoscalerServiceInvalidApplicationPolicyExceptionException e) {
-			throw new RestAPIException(e);
+			String msg = "Could not add application policy. Invalid application policy. " + e.getLocalizedMessage();
+			log.error(msg, e);
+			throw new RestAPIException(msg);
 		}
     }
     
@@ -601,13 +609,21 @@ public class StratosApiV41Utils {
             try {
 				autoscalerServiceClient.updateApplicationPolicy(applicationPolicy);
 			} catch (RemoteException e) {
-				throw new RestAPIException(e);
+				String msg = "Could not update application policy" + e.getLocalizedMessage();
+				log.error(msg, e);
+				throw new RestAPIException(msg);
 			} catch (AutoscalerServiceApplicatioinPolicyNotExistsExceptionException e) {
-				throw new RestAPIException(e);
+				String msg = "Could not update application policy. Application policy not exists" + e.getLocalizedMessage();
+				log.error(msg, e);
+				throw new RestAPIException(msg);
 			} catch (AutoscalerServiceRemoteExceptionException e) {
-				throw new RestAPIException(e);
+				String msg = "Could not update application policy" + e.getLocalizedMessage();
+				log.error(msg, e);
+				throw new RestAPIException(msg);
 			} catch (AutoscalerServiceInvalidApplicationPolicyExceptionException e) {
-				throw new RestAPIException(e);
+				String msg = "Could not update application policy. Invalid application policy" + e.getLocalizedMessage();
+				log.error(msg, e);
+				throw new RestAPIException(msg);
 			}
         }
     }
@@ -620,7 +636,9 @@ public class StratosApiV41Utils {
             try {
 				applicationPolicies = autoscalerServiceClient.getApplicationPolicies();
 			} catch (RemoteException e) {
-				throw new RestAPIException(e);
+				String msg = "Could not get application policies" + e.getLocalizedMessage();
+				log.error(msg, e);
+				throw new RestAPIException(msg);
 			}
         }
         return ObjectConverter.convertASStubApplicationPoliciesToApplicationPolicies(applicationPolicies);
@@ -669,9 +687,13 @@ public class StratosApiV41Utils {
     	try {
 			serviceClient.removeApplicationPolicy(applicationPolicyId);
 		} catch (RemoteException e) {
-			throw new RestAPIException(e);
+			String msg = "Could not remove application policy. " + e.getLocalizedMessage();
+			log.error(msg, e);
+			throw new RestAPIException(msg);
 		} catch (AutoscalerServiceInvalidPolicyExceptionException e) {
-			throw new RestAPIException(e);
+			String msg = "Could not update application policy. " + e.getLocalizedMessage();
+			log.error(msg, e);
+			throw new RestAPIException(msg);
 		}
     }