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

Commit 0727bfc

Browse files
AbhishekGarggkalpak
authored andcommitted
docs($http): add better explanation for error status codes
Add explanation for error status codes in `$http` and mention negative codes normalization. This alleviates confusion about which status codes will trigger the error callback and what values to expect in such callbacks. Fixes #11945 Closes #14459
1 parent 253cb8d commit 0727bfc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/ng/http.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,13 @@ function $HttpProvider() {
450450
* - **config** – `{Object}` – The configuration object that was used to generate the request.
451451
* - **statusText** – `{string}` – HTTP status text of the response.
452452
*
453-
* A response status code between 200 and 299 is considered a success status and
454-
* will result in the success callback being called. Note that if the response is a redirect,
455-
* XMLHttpRequest will transparently follow it, meaning that the error callback will not be
456-
* called for such responses.
453+
* A response status code between 200 and 299 is considered a success status and will result in
454+
* the success callback being called. Any response status code outside of that range is
455+
* considered an error status and will result in the error callback being called.
456+
* Also, status codes less than -1 are normalized to zero. -1 usually means the request was
457+
* aborted, e.g. using a `config.timeout`.
458+
* Note that if the response is a redirect, XMLHttpRequest will transparently follow it, meaning
459+
* that the outcome (success or error) will be determined by the final response status code.
457460
*
458461
*
459462
* ## Shortcut methods

0 commit comments

Comments
 (0)