Skip to content
Permalink
Browse files

Centralize the logic for throwing exceptions. Fixes #5913.

  • Loading branch information
jeresig committed Jan 23, 2010
1 parent 3e28644 commit a6ef036bb6a3610431471eebc2623bf8ad06bdd6
Showing with 7 additions and 3 deletions.
  1. +2 −2 src/ajax.js
  2. +1 −1 src/attributes.js
  3. +4 −0 src/core.js
@@ -578,7 +578,7 @@ jQuery.extend({
data = xml ? xhr.responseXML : xhr.responseText;

if ( xml && data.documentElement.nodeName === "parsererror" ) {
throw "parsererror";
jQuery.error( "parsererror" );
}

// Allow a pre-filtering function to sanitize the response
@@ -606,7 +606,7 @@ jQuery.extend({
}

} else {
throw "Invalid JSON: " + data;
jQuery.error( "Invalid JSON: " + data );
}

// If the type is "script", eval it in global context
@@ -281,7 +281,7 @@ jQuery.extend({
if ( set ) {
// We can't allow the type property to be changed (since it causes problems in IE)
if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
throw "type property can't be changed";
jQuery.error( "type property can't be changed" );
}

elem[ name ] = value;
@@ -466,6 +466,10 @@ jQuery.extend({
}
return true;
},

error: function( msg ) {
throw msg;
},

noop: function() {},

3 comments on commit a6ef036

@curiousdannii

This comment has been minimized.

Copy link

@curiousdannii curiousdannii replied Jan 26, 2010

Isn't something needed to map from Sizzle.error to jQuery.error (as Sizzle.error isn't exposed)?

@jeresig

This comment has been minimized.

Copy link
Member Author

@jeresig jeresig replied Jan 26, 2010

You can get to Sizzle.error by overriding jQuery.find.error (jQuery.find is Sizzle). I kept these two functions separate because I figured that some might want to differentiate between a selector error and a jQuery-specific error.

@curiousdannii

This comment has been minimized.

Copy link

@curiousdannii curiousdannii replied Jan 26, 2010

Ahhh yes. Brain fail, sorry!

Please sign in to comment.
You can’t perform that action at this time.