-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($http) Indicate whether a request was aborted via status. #4491
Comments
+1, I like it. Send a PR! |
Can we do more than just propagate the status? A promise can be aborted via the timeout promise for any reason, it would be nice if the aborted reason is propagated as well. Can we stringify the reject reason and propagated it through statusText? |
@yozo1984 I'm not big fan of string-based APIs so I would prefer assign different status codes if we want to distinguish between timeout and promise-based aborting. We could obviously add proper status text, I'm just saying that that we should have proper status codes if we want to go down this path. |
@pkozlowski-opensource How about put the aborted reason in the data field? Then it doesn't have to be string and can be live as blank like it is now. |
@yozo1984 not sure I understand what you mean by data field... I don't think you've meant the same data object that holds data returned from the server, this would be bad idea, IMO. Anyway, I don't think there is much problem with coming up with "artificial" abort statuses, ex. -1 for promise and -2 for timeout or something and adding informative status text on top. |
@pkozlowski-opensource Sounds good. You are right. Second thoughts on the data field things and lots of problem comes out of it. Thank you for working on this. |
Currently, there does not appear to be a way to determine whether a request was aborted or failed for another reason, as status is normalized to 0 in $http:
Internally a -1 is used to flag that the request either timed out or it was aborted via promise resolution.
What if we exposed the -1 as a valid status to give a better idea to rejection handlers why the request failed?
If this is the case I can create a PR to adress this issue.
The text was updated successfully, but these errors were encountered: