@@ -18,10 +18,10 @@ const { |
18 | 18 |
|
19 | 19 | let DOMException; |
20 | 20 |
|
21 | | -const lazyDOMException = hideStackFrames((message) => { |
| 21 | +const lazyDOMException = hideStackFrames((message, name) => { |
22 | 22 | if (DOMException === undefined) |
23 | 23 | DOMException = internalBinding('messaging').DOMException; |
24 | | - return new DOMException(message); |
| 24 | + return new DOMException(message, name); |
25 | 25 | }); |
26 | 26 |
|
27 | 27 | function setTimeout(after, value, options = {}) { |
@@ -54,8 +54,10 @@ function setTimeout(after, value, options = {}) { |
54 | 54 | // TODO(@jasnell): If a decision is made that this cannot be backported |
55 | 55 | // to 12.x, then this can be converted to use optional chaining to |
56 | 56 | // simplify the check. |
57 | | - if (signal && signal.aborted) |
58 | | - return PromiseReject(lazyDOMException('AbortError')); |
| 57 | + if (signal && signal.aborted) { |
| 58 | + return PromiseReject( |
| 59 | + lazyDOMException('The operation was aborted', 'AbortError')); |
| 60 | + } |
59 | 61 | return new Promise((resolve, reject) => { |
60 | 62 | const timeout = new Timeout(resolve, after, args, false, true); |
61 | 63 | if (!ref) timeout.unref(); |
@@ -65,7 +67,7 @@ function setTimeout(after, value, options = {}) { |
65 | 67 | if (!timeout._destroyed) { |
66 | 68 | // eslint-disable-next-line no-undef |
67 | 69 | clearTimeout(timeout); |
68 | | - reject(lazyDOMException('AbortError')); |
| 70 | + reject(lazyDOMException('The operation was aborted', 'AbortError')); |
69 | 71 | } |
70 | 72 | }, { once: true }); |
71 | 73 | } |
@@ -101,8 +103,10 @@ function setImmediate(value, options = {}) { |
101 | 103 | // TODO(@jasnell): If a decision is made that this cannot be backported |
102 | 104 | // to 12.x, then this can be converted to use optional chaining to |
103 | 105 | // simplify the check. |
104 | | - if (signal && signal.aborted) |
105 | | - return PromiseReject(lazyDOMException('AbortError')); |
| 106 | + if (signal && signal.aborted) { |
| 107 | + return PromiseReject( |
| 108 | + lazyDOMException('The operation was aborted', 'AbortError')); |
| 109 | + } |
106 | 110 | return new Promise((resolve, reject) => { |
107 | 111 | const immediate = new Immediate(resolve, [value]); |
108 | 112 | if (!ref) immediate.unref(); |
@@ -111,7 +115,7 @@ function setImmediate(value, options = {}) { |
111 | 115 | if (!immediate._destroyed) { |
112 | 116 | // eslint-disable-next-line no-undef |
113 | 117 | clearImmediate(immediate); |
114 | | - reject(lazyDOMException('AbortError')); |
| 118 | + reject(lazyDOMException('The operation was aborted', 'AbortError')); |
115 | 119 | } |
116 | 120 | }, { once: true }); |
117 | 121 | } |
|