Skip to content
Permalink
Browse files
Catch one more place where a plain-text error was thrown.
  • Loading branch information
dmethvin committed Nov 8, 2011
1 parent f0e43fa commit cc4a999648d2623972e6dabad0e6c4b1bb60458a
Showing 1 changed file with 1 addition and 1 deletion.
@@ -546,7 +546,7 @@ jQuery.extend({
} catch(e) {
// We have a parsererror
statusText = "parsererror";
error = e;
error = e.message;
}
}
} else {

3 comments on commit cc4a999

@jaubourg
Copy link
Member

@jaubourg jaubourg commented on cc4a999 Nov 8, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... you probably shouldn't here. We're supposed to give the exception object to the error callbacks. What are we trying to handle here exactly ?

@dmethvin
Copy link
Member Author

@dmethvin dmethvin commented on cc4a999 Nov 8, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good, daddy is here! :)

IE won't give the user any useful error information if a plain string is thrown, so we changed jQuery.error to throw new Error(msg) instead. Since ajax uses it to throw in the transports I needed to find the places it was expecting strings. Thoughts?

@jaubourg
Copy link
Member

@jaubourg jaubourg commented on cc4a999 Nov 8, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's not actually expecting a string here, because it's catching around the use of converters (where native exceptions can be thrown depending on how such or such converter is implemented). The third parameter of the error callbacks (which is the sole use of the error variable here) is supposed to be the original exception whenever available. In fact same goes for transports actually.

Please sign in to comment.