Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

$http error callback doesn't have xhr.statusText #2335

Closed
phillycoder opened this issue Apr 8, 2013 · 23 comments
Closed

$http error callback doesn't have xhr.statusText #2335

phillycoder opened this issue Apr 8, 2013 · 23 comments

Comments

@phillycoder
Copy link

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

@danbarua
Copy link
Contributor

+1 Just ran into this.

@phillycoder
Copy link
Author

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

@danbarua
Copy link
Contributor

@jimlyndon thank you!

@jimlyndon
Copy link
Contributor

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

@phillycoder
Copy link
Author

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

@protoze
Copy link

protoze commented Jun 15, 2013

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.

@jimlyndon
Copy link
Contributor

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//issues/2335#issuecomment-19491846
.

jimlyndon added a commit to jimlyndon/angular.js that referenced this issue Jul 17, 2013
@markbarton
Copy link

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

@mikeobrien
Copy link

Ug, same here, need this. 👍

@adamspe
Copy link

adamspe commented Jan 9, 2014

+1

@ferconsigli
Copy link

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

@Darmikon
Copy link

statusText is very important, please add it to response

@acollard
Copy link

acollard commented Mar 1, 2014

+1

@welsh-dwarf
Copy link

+1, just hit this.

caitp pushed a commit to caitp/angular.js that referenced this issue Mar 17, 2014
caitp pushed a commit to caitp/angular.js that referenced this issue Mar 17, 2014
caitp pushed a commit to caitp/angular.js that referenced this issue Mar 26, 2014
caitp pushed a commit to caitp/angular.js that referenced this issue Mar 27, 2014
caitp pushed a commit to caitp/angular.js that referenced this issue Mar 27, 2014
@caitp caitp closed this as completed in 1d2414c Mar 27, 2014
caitp pushed a commit that referenced this issue Mar 27, 2014
Makes xhr status text accessible is $http success/error callback.
See www.w3.org/TR/XMLHttpRequest/#dom-xmlhttprequest-statustext

Closes #2335
Closes #2665
Closes #6713
@iSchlicht
Copy link

+1

@tamalnath
Copy link

I faced the same problem on version 1.2.24

@petebacondarwin
Copy link
Contributor

Is this not available in 1.2.24: See 32c09c1

@owen26
Copy link

owen26 commented Oct 23, 2014

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;
  };

@caitp
Copy link
Contributor

caitp commented Oct 23, 2014

@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?

@tamalnath
Copy link

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

@OzBob
Copy link

OzBob commented Feb 12, 2015

here's the work around to get StatusText (as pointed out that some moblie browsers strip out DATA from successfull responses: http://stackoverflow.com/a/28470163/1586498

@oyevtushok
Copy link

Not sure if it'll work for everyone, but you can use then/catch. First argument of catch contains both statusText and status(which is response code) properties

@stefanofornari
Copy link

+1 to get this fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.