I have the following code:

$http.get('someUrl').then(function(response){ //что-то }, function(error){ //что-то }); 

The server does not know someUrl, sends 404, but the first callback is executed, why? Version angular.js 1.3.15.

Update

I tried through the success and error methods - the same.

No 4xx error causes a callback error.

    1 answer 1

    then works anyway, since $http.get() returns promise. Error - the event must occur in software or by protocol. 404 is the http puncture error code, not the js , angular or promise protocol. If you need to process error 404 , then process it explicitly. Write the appropriate callback in the first callback . If you need to work directly with exceptions, then nothing prevents you from doing something like:

     if (response.code === 404) throw Error({error: 404, errorMessage: "Нет такого ресурса."}); 

    You can do this explicitly in the first callback or define your own type of "resource": https://docs.angularjs.org/api/ngResource/service/$resource - here you have great opportunities to determine the behavior yourself.