handle response null with status code in REST handler

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

Branch: refs/heads/master
Commit: f71cd41699a46781034d6a3b2503cfbf07313cd2
Parents: f876da4
Author: Dakshika Jayathilaka <[email protected]>
Authored: Tue Jan 27 16:43:22 2015 +0530
Committer: Dakshika Jayathilaka <[email protected]>
Committed: Tue Jan 27 16:43:22 2015 +0530

----------------------------------------------------------------------
 .../console/controllers/rest/rest_calls.jag               | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/f71cd416/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag
 
b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag
index 131ea7a..c8462de 100644
--- 
a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag
+++ 
b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag
@@ -299,14 +299,20 @@ RESTCalls = new function(){
         } else if (response.xhr.status >= 300 && response.xhr.status < 400) { 
//if redirects
             if(response.data != null && response.data != undefined) {
                 session.put("get-status", { "message": 
parse(response.data).Error.errorMessage , "status": "warning" } );
+            }else{
+                session.put("get-status", { "message":  response.xhr.status + 
' '+ response.xhr.statusText , "status": "warning"});
             }
         } else if (response.xhr.status >= 400 && response.xhr.status < 500) { 
//if client error
             if(response.data != null && response.data != undefined) {
                 session.put("get-status",{ "message":  
parse(response.data).Error.errorMessage, "status": "warning" } );
+            }else{
+                session.put("get-status", { "message":  response.xhr.status + 
' '+ response.xhr.statusText , "status": "warning"});
             }
         } else if (response.xhr.status >= 500 && response.xhr.status < 600) { 
//if server error
             if(response.data != null && response.data != undefined) {
                 session.put("get-status", { "message": 
parse(response.data).Error.errorMessage, "status": "warning" } );
+            }else{
+                session.put("get-status", { "message":  response.xhr.status + 
' '+ response.xhr.statusText , "status": "warning"});
             }
         } else {
             session.put("get-status", "Unknown response!");
@@ -350,6 +356,8 @@ RESTCalls = new function(){
         } else if (response.xhr.status >= 300 && response.xhr.status < 400) { 
//if redirects
             if(response.data != null && response.data != undefined) {
                 session.put("deploy-status",{ "message": 
parse(response.data).Error.errorMessage, "status": "warning" } );
+            }else{
+                session.put("deploy-status", { "message":  response.xhr.status 
+ ' '+ response.xhr.statusText , "status": "warning"});
             }
         } else if (response.xhr.status >= 400 && response.xhr.status < 500) { 
//if client error
             if(response.data != null && response.data != undefined) {
@@ -360,6 +368,8 @@ RESTCalls = new function(){
         } else if (response.xhr.status >= 500 && response.xhr.status < 600) { 
//if server error
             if(response.data != null && response.data != undefined) {
                 session.put("deploy-status", { "message": 
parse(response.data).Error.errorMessage, "status": "error"});
+            }else{
+                session.put("deploy-status", { "message":  response.xhr.status 
+ ' '+ response.xhr.statusText , "status": "error"});
             }
         } else {
             session.put("deploy-status", "Unknown response!");

Reply via email to