I got a behaviour I don't understand on an application using Spring and angular. An exception is Thrown in the http request. I did the test below.
@RequestMapping(value = "/contract/upload/excel", method = RequestMethod.POST)
public String uploadContractExcel(HttpServletRequest request, ModelMap model) {
if(true) {
throw new RuntimeException("my code is broken");
}
...
In JavaScript in the $http function instead of going into the error block, it returns to the success block with Status code 200 - OK. So I cannot handle any exception.
$http({
method : 'POST',
url : resolveAjax,
data : formData
}).then(
function successCallback(response) {
var data = response.data;
if (data.upload_error === "true") {
$scope.busy = false;
$scope.upload_error_message = data.upload_error_message;
} else {
$scope.contractSummary = angular
.fromJson(data.reference_excel_resolved);
$scope.busy = false;
$scope.tabindex = $scope.tabindex * 1 + 1;
}
},
function errorCallback(response) {
$scope.upload_error_message = 'Oups something went wrong';
});
Has anybody got an idea about what happens ? Thanks