Updated Branches:
  refs/heads/master 029cca0e3 -> 621e7b8c3

handling errors correctly at cli end; simply passing the error json sent by 
backend after wrapping to an object


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

Branch: refs/heads/master
Commit: 44223db10a48838ccc93e578ed84e2be8c78fd09
Parents: b2ba823
Author: Nirmal Fernando <[email protected]>
Authored: Fri Feb 14 16:43:11 2014 +0530
Committer: Nirmal Fernando <[email protected]>
Committed: Fri Feb 14 16:43:11 2014 +0530

----------------------------------------------------------------------
 .../stratos/cli/RestCommandLineService.java     | 54 ++++++++++++--------
 1 file changed, 33 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/44223db1/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
index e503ffc..b693f16 100644
--- 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
@@ -208,18 +208,20 @@ public class RestCommandLineService {
                     restClientService.getUsername(), 
restClientService.getPassword());
 
             String responseCode = "" + 
response.getStatusLine().getStatusCode();
-            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
-                System.out.println("Error occured while listing available 
cartridges");
-                return;
-            }
-
             String resultString = getHttpResponseString(response);
             if (resultString == null) {
-                return;
+               return;
             }
-
+            
             GsonBuilder gsonBuilder = new GsonBuilder();
             Gson gson = gsonBuilder.create();
+            
+            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+               ExceptionMapper exception = gson.fromJson(resultString, 
ExceptionMapper.class);
+               System.out.println(exception);
+                return;
+            }
+
             CartridgeList cartridgeList = gson.fromJson(resultString, 
CartridgeList.class);
 
             if (cartridgeList == null) {
@@ -300,18 +302,20 @@ public class RestCommandLineService {
                     restClientService.getUsername(), 
restClientService.getPassword());
 
             String responseCode = "" + 
response.getStatusLine().getStatusCode();
-            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
-                System.out.println("Error occured while listing available 
cartridges");
-                return;
-            }
-
             String resultString = getHttpResponseString(response);
             if (resultString == null) {
-                return;
+               return;
             }
-
+            
             GsonBuilder gsonBuilder = new GsonBuilder();
             Gson gson = gsonBuilder.create();
+            
+            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+               ExceptionMapper exception = gson.fromJson(resultString, 
ExceptionMapper.class);
+               System.out.println(exception);
+                return;
+            }
+
             CartridgeList cartridgeList = gson.fromJson(resultString, 
CartridgeList.class);
 
             if (cartridgeList == null) {
@@ -342,15 +346,17 @@ public class RestCommandLineService {
                     restClientService.getUsername(), 
restClientService.getPassword());
 
             String responseCode = "" + 
response.getStatusLine().getStatusCode();
+            String resultString = getHttpResponseString(response);
+            
+            GsonBuilder gsonBuilder = new GsonBuilder();
+            Gson gson = gsonBuilder.create();
+            
             if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
-                System.out.println("Error occured while listing subscribe 
cartridges");
+               ExceptionMapper exception = gson.fromJson(resultString, 
ExceptionMapper.class);
+               System.out.println(exception);
                 return;
             }
 
-            String resultString = getHttpResponseString(response);
-
-            GsonBuilder gsonBuilder = new GsonBuilder();
-            Gson gson = gsonBuilder.create();
             CartridgeList cartridgeList = gson.fromJson(resultString, 
CartridgeList.class);
 
             if (cartridgeList == null) {
@@ -605,8 +611,12 @@ public class RestCommandLineService {
                     restClientService.getUsername(), 
restClientService.getPassword());
 
             String responseCode = "" + 
response.getStatusLine().getStatusCode();
+            
+            Gson gson = new Gson();
             if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
-                System.out.println("Error occured while listing members of a 
cluster");
+               String resultString = getHttpResponseString(response);
+               ExceptionMapper exception = gson.fromJson(resultString, 
ExceptionMapper.class);
+               System.out.println(exception);
                 return null;
             }
 
@@ -854,7 +864,9 @@ public class RestCommandLineService {
                 System.out.println("Error occured while creating tenant");
                 return;
             } else {
-                System.out.println ("Unhandle error");
+               String resultString = getHttpResponseString(response);
+               ExceptionMapper exception = gson.fromJson(resultString, 
ExceptionMapper.class);
+               System.out.println(exception);
                 return;
             }
 

Reply via email to