diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2023-03-14 22:32:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 22:32:45 +0100 |
commit | 258ca1ec6a373f85f7849308c967b7e6a993e6e7 (patch) | |
tree | 085396fc342655770c8578781fe230f05ac69727 /src/deferred | |
parent | f088c36631df3d5dc98408debd147ea5d3618557 (diff) | |
download | jquery-258ca1ec6a373f85f7849308c967b7e6a993e6e7.tar.gz jquery-258ca1ec6a373f85f7849308c967b7e6a993e6e7.zip |
Deferred: Rename `getStackHook` to `getErrorHook`
Rename `jQuery.Deferred.getStackHook` to `jQuery.Deferred.getErrorHook`
to indicate passing an error instance is usually a better choice - it
works with source maps while a raw stack generally does not.
In jQuery `3.7.0`, we'll keep both names, marking the old one as
deprecated. In jQuery `4.0.0` we'll just keep the new one. This
change implements the `4.0.0` version; PR gh-5212 implements
the `3.7.0` one.
Fixes gh-5201
Closes gh-5211
Ref gh-5212
Diffstat (limited to 'src/deferred')
-rw-r--r-- | src/deferred/exceptionHook.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/deferred/exceptionHook.js b/src/deferred/exceptionHook.js index 0315b2ecb..a5e7b5d3c 100644 --- a/src/deferred/exceptionHook.js +++ b/src/deferred/exceptionHook.js @@ -6,13 +6,16 @@ import "../deferred.js"; // warn about them ASAP rather than swallowing them by default. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; -jQuery.Deferred.exceptionHook = function( error, stack ) { +// If `jQuery.Deferred.getErrorHook` is defined, `asyncError` is an error +// captured before the async barrier to get the original error cause +// which may otherwise be hidden. +jQuery.Deferred.exceptionHook = function( error, asyncError ) { if ( error && rerrorNames.test( error.name ) ) { window.console.warn( "jQuery.Deferred exception", error, - stack + asyncError ); } }; |