Skip to content

Commit

Permalink
jQuery.error: Don't advertise assigning jQuery.error to console.error
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mgol committed Jun 12, 2023
1 parent 72e6a91 commit 88b9286
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions entries/jQuery.error.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
<desc>Takes a string and throws an exception containing it.</desc>
<longdesc>
<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>
<p>If you do override the method, remember to still throw an error at the end to preserve semantics.</p>
</longdesc>
<example>
<desc>Override jQuery.error for display in Firebug.</desc>
<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>
<code><![CDATA[
jQuery.error = console.error;
jQuery.error = function( message ) {
sendErrorLog( "jQuery error: " + message );
throw new Error( message );
};
]]></code>
</example>
<category slug="internals"/>
Expand Down

0 comments on commit 88b9286

Please sign in to comment.