Skip to content

Commit

Permalink
Take 2 on "Fix ajax to always expect an Error object, per #10646."
Browse files Browse the repository at this point in the history
We can't use jQuery.error to rethrow anymore since it constructs a new Error from its supposedly-string arg. Also, older IE stringifies Error objects into "[object Error]" so I've loosened the unit test criteria.

This reverts commit 586fb05.
  • Loading branch information
dmethvin committed Nov 8, 2011
1 parent d8e2b4b commit c3600e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ajax.js
Expand Up @@ -752,10 +752,10 @@ jQuery.extend({
} catch (e) { } catch (e) {
// Propagate exception as error if not done // Propagate exception as error if not done
if ( state < 2 ) { if ( state < 2 ) {
done( -1, e.message ); done( -1, e );
// Simply rethrow otherwise // Simply rethrow otherwise
} else { } else {
jQuery.error( e.message ); throw e;
} }
} }
} }
Expand Down
2 changes: 1 addition & 1 deletion test/unit/ajax.js
Expand Up @@ -1616,7 +1616,7 @@ test("jQuery.ajax() - malformed JSON", function() {
}, },
error: function(xhr, msg, detailedMsg) { error: function(xhr, msg, detailedMsg) {
equal( "parsererror", msg, "A parse error occurred." ); equal( "parsererror", msg, "A parse error occurred." );
ok( /^(Invalid|SyntaxError|exception)/i.test(detailedMsg), "Detailed parsererror message provided" ); ok( /(invalid|error|exception)/i.test(detailedMsg), "Detailed parsererror message provided" );
start(); start();
} }
}); });
Expand Down

0 comments on commit c3600e2

Please sign in to comment.