@@ -18,10 +18,10 @@ const {
1818
1919let DOMException ;
2020
21- const lazyDOMException = hideStackFrames ( ( message ) => {
21+ const lazyDOMException = hideStackFrames ( ( message , name ) => {
2222 if ( DOMException === undefined )
2323 DOMException = internalBinding ( 'messaging' ) . DOMException ;
24- return new DOMException ( message ) ;
24+ return new DOMException ( message , name ) ;
2525} ) ;
2626
2727function setTimeout ( after , value , options = { } ) {
@@ -54,8 +54,10 @@ function setTimeout(after, value, options = {}) {
5454 // TODO(@jasnell): If a decision is made that this cannot be backported
5555 // to 12.x, then this can be converted to use optional chaining to
5656 // 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+ }
5961 return new Promise ( ( resolve , reject ) => {
6062 const timeout = new Timeout ( resolve , after , args , false , true ) ;
6163 if ( ! ref ) timeout . unref ( ) ;
@@ -65,7 +67,7 @@ function setTimeout(after, value, options = {}) {
6567 if ( ! timeout . _destroyed ) {
6668 // eslint-disable-next-line no-undef
6769 clearTimeout ( timeout ) ;
68- reject ( lazyDOMException ( 'AbortError' ) ) ;
70+ reject ( lazyDOMException ( 'The operation was aborted' , ' AbortError') ) ;
6971 }
7072 } , { once : true } ) ;
7173 }
@@ -101,8 +103,10 @@ function setImmediate(value, options = {}) {
101103 // TODO(@jasnell): If a decision is made that this cannot be backported
102104 // to 12.x, then this can be converted to use optional chaining to
103105 // 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+ }
106110 return new Promise ( ( resolve , reject ) => {
107111 const immediate = new Immediate ( resolve , [ value ] ) ;
108112 if ( ! ref ) immediate . unref ( ) ;
@@ -111,7 +115,7 @@ function setImmediate(value, options = {}) {
111115 if ( ! immediate . _destroyed ) {
112116 // eslint-disable-next-line no-undef
113117 clearImmediate ( immediate ) ;
114- reject ( lazyDOMException ( 'AbortError' ) ) ;
118+ reject ( lazyDOMException ( 'The operation was aborted' , ' AbortError') ) ;
115119 }
116120 } , { once : true } ) ;
117121 }
0 commit comments