Skip to content

Commit 88b9286

Browse files
authored
jQuery.error: Don't advertise assigning jQuery.error to console.error
The original implementation of `jQuery.error` throws an error. When overwritten, it should still finish by throwing an error to avoid observable differences in behavior. Closes gh-1233
1 parent 72e6a91 commit 88b9286

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

entries/jQuery.error.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
<desc>Takes a string and throws an exception containing it.</desc>
1111
<longdesc>
1212
<p>This method exists primarily for plugin developers who wish to override it and provide a better display (or more information) for the error messages.</p>
13+
<p>If you do override the method, remember to still throw an error at the end to preserve semantics.</p>
1314
</longdesc>
1415
<example>
15-
<desc>Override jQuery.error for display in Firebug.</desc>
16+
<desc>Override <code>jQuery.error</code> to send it to a logging service, assuming the <code>sendErrorLog</code> method is provided by this service.</desc>
1617
<code><![CDATA[
17-
jQuery.error = console.error;
18+
jQuery.error = function( message ) {
19+
sendErrorLog( "jQuery error: " + message );
20+
throw new Error( message );
21+
};
1822
]]></code>
1923
</example>
2024
<category slug="internals"/>

0 commit comments

Comments
 (0)