title: Angularjs http request doesn't go in errorCallback
body: <p>I'm using angularjs to call my Rest web services but I have a problem with error handle.
  This is one of my http calls:</p>
  
  <pre><code>$http({
      method: 'POST',
      url: "tr"+licenseSelected,//angular need string in url
      headers: {'Content-Type': 'application/json'},
      data : updatedLicense,
      beforeSend: function() {
          waitingModal.showPleaseWait();
      },
      complete: function() {
          setTimeout(function(){
              waitingModal.hidePleaseWait();
          }, 1000);
      }
  }).then(function successCallback(response) {
      if (response.data.success==true){   
          licenseTable.ajax.reload();
          $('#updateLicenseModal').modal("hide");
          notifyMessage(response.data.result, 'success');
      } else {
          notifyMessage(response.data.result, 'error');
      }                       
  }, function errorCallback(response) {
      window.location.href = "/ATS/500";
  });
  </code></pre>
  
  <p>I would like to show 500 page if an error occurred during http request (for example server down or wrong url), but errorCallback is never called.
  Is there an error in my code? where is my fault?Thanks
  This is an example of response that I can't handle in error code:</p>
  
  <pre><code>{
  "status":422,
  "exception":"org.springframework.web.method.annotation.MethodArgumentTypeMismatchException",
  "message":"Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: \"tr71\"",
  "stacktrace":"org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: \"tr71\"
  at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:115)
      at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:78)    
      at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162)
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:129)
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:111)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:806)
      ......"
  }
  </code></pre>
  
  <p>Web service example</p>
  
  <pre><code>@Override
      @RequestMapping(value = { "/license"}, method = RequestMethod.POST)
      public @ResponseBody Response createLicense(@RequestBody ClientLicenseForm clientLicenseForm) {
          try{
              administrationService.createLicense(clientLicenseForm);
              return new Response(true, true, "Your license has been created!", null);
          }catch(Exception e){
              ErrorResponse errorResponse= ErrorResponseBuilder.buildErrorResponse(e);
              LOG.error("Threw exception in AdministrationControllerImpl::createLicense :" + errorResponse.getStacktrace());
              return new Response(false,false,"Error! Your license hasn't been created!",errorResponse);
          }
      }
  </code></pre>
  
  <p>This may be the problem(it wrap json response inside another object), but how can I fix it?
  <a href="https://i.stack.imgur.com/3h9wL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3h9wL.jpg" alt="enter image description here"></a></p>
  
  <p><strong><em>UPDATE</em></strong>
  I have fixed with this code, I'll test it</p>
  
  <pre><code>}).then(function successCallback(response) {
              if (typeof response.data.success == 'undefined'){
                  window.location.href = "/ATS/500";
              }else if (response.data.success==true){ 
                  licenseTable.ajax.reload();
                  $('#updateLicenseModal').modal("hide");
                  notifyMessage(response.data.result, 'success');
              } else if(response.data.success==false) {
                  notifyMessage(response.data.result, 'error');   
              }
          }, function errorCallback(response) {
              window.location.href = "/ATS/500";
          });
  </code></pre>