diff options
author | jeresig <jeresig@gmail.com> | 2010-01-23 16:48:47 -0500 |
---|---|---|
committer | jeresig <jeresig@gmail.com> | 2010-01-23 16:48:47 -0500 |
commit | a6ef036bb6a3610431471eebc2623bf8ad06bdd6 (patch) | |
tree | f39eaced2186fadd83481bae96d901d7a55595b1 | |
parent | 3e286440d55749382a644ea97b4f0b2587779d65 (diff) | |
download | jquery-a6ef036bb6a3610431471eebc2623bf8ad06bdd6.tar.gz jquery-a6ef036bb6a3610431471eebc2623bf8ad06bdd6.zip |
Centralize the logic for throwing exceptions. Fixes #5913.
-rw-r--r-- | src/ajax.js | 4 | ||||
-rw-r--r-- | src/attributes.js | 2 | ||||
-rw-r--r-- | src/core.js | 4 |
3 files changed, 7 insertions, 3 deletions
diff --git a/src/ajax.js b/src/ajax.js index f1de0f8c5..502f00653 100644 --- a/src/ajax.js +++ b/src/ajax.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 diff --git a/src/attributes.js b/src/attributes.js index 004c6b30c..82a4de1bd 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -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; diff --git a/src/core.js b/src/core.js index 4102e5c8c..3ff95e020 100644 --- a/src/core.js +++ b/src/core.js @@ -466,6 +466,10 @@ jQuery.extend({ } return true; }, + + error: function( msg ) { + throw msg; + }, noop: function() {}, |