Best Practise when dealing with $http / $ajax requests

I have a question regarding the best practices in Phalcon's controller when handing view requests. For example the following case:

From the view:

$http({method: 'GET', url: '/getObject'}).
  success(function(data, status, headers, config) {

  error(function(data, status, headers, config) {


When an exception occurs inside the controller action, the response is still 200 OK which triggers the success function. Is there a way to modify this behaviour (when an exception is thrown from the controller) or should i modify the response object when an error occurs? What are the best practises when dealing with these kind of situations?


I think here is 2 way, u set the header when u catch the exception, or u handle the error on the success function. :)