Skip to content

Commit

Permalink
Update response for error status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
alechenninger committed Apr 5, 2015
1 parent a6fc718 commit 56391cf
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions data-mgmt/src/main/webapp/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,22 @@ var dataManageControllers = angular.module("dataManageControllers", ["dataManage

var config = makeLightblueRequest(emptyFilter($scope.request.body));

dataService[view](config)
.success(function(data, status, headers) {
function updateResponse(data, status, headers) {
var contentType = headers("Content-Type");

if (typeof contentType === "string"
&& contentType.indexOf("application/json") === 0) {
angular.copy(data, $scope.response);
})
} else {
$scope.response = "Non-json response received, status code: " + status + "\n" +
"This usually indicates a problem with the application.\n" +
"Please open an issue: https://github.com/lightblue-platform/lightblue-applications/issues/new";
}
}

dataService[view](config)
.success(updateResponse)
.error(updateResponse)
.finally(function() {
$scope.loading = false;
});
Expand Down

0 comments on commit 56391cf

Please sign in to comment.