angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

$http error callback doesn't have xhr.statusText

Open phillycoder opened this issue 13 years ago • 23 comments

There is no way to get XHR statusText in $http error callback. Currently this only returns status(number - statusCode).

It would be really helpful to get status text to display the server error message in the browser.

Like examples, 404 - Resource not found 400 - User ID already exists

phillycoder avatar Apr 08 '13 20:04 phillycoder

+1 Just ran into this.

danbarua avatar Apr 24 '13 16:04 danbarua

@jimlyndon thx for the fix, i hope your pull request will be accepted.

phillycoder avatar May 20 '13 17:05 phillycoder

@jimlyndon thank you!

danbarua avatar May 21 '13 08:05 danbarua

No prob. I have a story on the wall waiting for this fix as well. So we'll see :)

jimlyndon avatar May 22 '13 00:05 jimlyndon

Hi Guys, Anyone know if this is fixed in the trunk?

phillycoder avatar Jun 13 '13 02:06 phillycoder

We're working with another team's backend that we don't really have control over and it would be really nice if we could leverage that system's existing error messages by using the status text.

protoze avatar Jun 15 '13 05:06 protoze

The PR mentioned above hasn't been pulled, and I don't know if the fix has been satisfied by another, as I haven't heard back from anyone on the PR and have been off the grid w other projects.

But it's an easy fix and super useful. Feel free to comment on the PR thread also. On Jun 15, 2013 3:58 PM, "protoze" [email protected] wrote:

We're working with another team's backend that we don't really have control over and it would be really nice if we could leverage that system's existing error messages by using the status text.

— Reply to this email directly or view it on GitHubhttps://github.com/angular/angular.js/issues/2335#issuecomment-19491846 .

jimlyndon avatar Jun 16 '13 06:06 jimlyndon

Yep just hit this issue as well = hopefully will be rolled in soon.

markbarton avatar Aug 21 '13 16:08 markbarton

Ug, same here, need this. :+1:

mikeobrien avatar Sep 12 '13 00:09 mikeobrien

+1

adamspe avatar Jan 09 '14 17:01 adamspe

Same here, we also need to get the status text of the responses.

ferconsigli avatar Jan 14 '14 19:01 ferconsigli

statusText is very important, please add it to response

Darmikon avatar Jan 30 '14 18:01 Darmikon

+1

acollard avatar Mar 01 '14 01:03 acollard

+1, just hit this.

welsh-dwarf avatar Mar 17 '14 14:03 welsh-dwarf

+1

iSchlicht avatar Aug 12 '14 09:08 iSchlicht

I faced the same problem on version 1.2.24

tamalnath avatar Sep 10 '14 08:09 tamalnath

Is this not available in 1.2.24: See https://github.com/angular/angular.js/commit/32c09c1d195fcb98f6e29fc7e554a867f4762301

petebacondarwin avatar Sep 10 '14 09:09 petebacondarwin

same problem on version 1.3.0

for a temporary solution for myself, changed source code as the following:

promise.success = function(fn) {
    promise.then(function(response) {
      fn(response.data, response.status, response.headers, config, response.statusText);
    });
    return promise;
  };

  promise.error = function(fn) {
    promise.then(null, function(response) {
      fn(response.data, response.status, response.headers, config, response.statusText);
    });
    return promise;
  };

owen26 avatar Oct 23 '14 05:10 owen26

@owen26 we probably arent going to extend those in core because if we ever want to add more it just gets really sucky. why not just use .then() for it?

caitp avatar Oct 23 '14 05:10 caitp

At least it should be documented somewhere saying statusText will only be available in .then() and not in .success()/.error().

tamalnath avatar Oct 23 '14 05:10 tamalnath