Opened 7 years ago

Closed 4 years ago

#16223 closed defect (fixed)

[patch] XHR returns wrong error name and messge

Reported by: Peter Jekel Owned by: Bryan Forbes
Priority: high Milestone: 1.11
Component: IO Version: 1.8.1
Keywords: Cc:
Blocked By: Blocking:

Description

When the 'handleAs' property is set and a network or server errors occurs, XHR invokes the data handler with the HTML server response. For example, if 'handleAs' is set to "json" and a HTTP 404 error occured, XHR takes the HTML server response and calls JSON.parse which will always return "SyntaxError?" instead of "NotFoundError?"

Attachments (2)

xhrTest.html (1.2 KB) - added by Peter Jekel 7 years ago.
Simple app. demonstrating the XHR issue.
xhr.patch (301 bytes) - added by Nebulae 4 years ago.

Download all attachments as: .zip

Change History (9)

Changed 7 years ago by Peter Jekel

Attachment: xhrTest.html added

Simple app. demonstrating the XHR issue.

comment:1 Changed 7 years ago by ben hockey

Component: GeneralIO
Owner: set to Bryan Forbes

comment:2 Changed 4 years ago by dylan

Milestone: tbd1.11

Bryan, do we have a test case for this in our Intern test cases for dojo/request?

comment:3 Changed 4 years ago by Nebulae

A solution to that may be by checking the status before handling the response ? Worked fine on my tests, but I'm not aware of any edge effect this may cause ...

Attached a patch for review

Changed 4 years ago by Nebulae

Attachment: xhr.patch added

comment:4 Changed 4 years ago by dylan

Summary: XHR returns wrong error name and messge[patch] XHR returns wrong error name and messge

comment:5 Changed 4 years ago by dylan

Priority: undecidedblocker

comment:6 Changed 4 years ago by dylan

Priority: blockerhigh

comment:7 Changed 4 years ago by dylan

Resolution: fixed
Status: newclosed

Changes made in https://github.com/dojo/dojo/commit/15175cb3d5afc19892304e6ee1cd196d008ce234

Note that we are not changing the behavior, as the expectation with handleAs: 'json' is that you are sending non-2XX responses as JSON also. So the change is to make that clearer in the way the error message is handled.

Note: See TracTickets for help on using tickets.