File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -821,8 +821,11 @@ function hideInternalStackFrames(error) {
821821// to make usage of the error in userland and readable-stream easier. 
822822// It is a regular error with `.code` and `.name`. 
823823class  AbortError  extends  Error  { 
824-   constructor ( )  { 
825-     super ( 'The operation was aborted' ) ; 
824+   constructor ( message  =  'The operation was aborted' ,  options  =  undefined )  { 
825+     if  ( options  !==  undefined  &&  typeof  options  !==  'object' )  { 
826+       throw  new  codes . ERR_INVALID_ARG_TYPE ( 'options' ,  'Object' ,  options ) ; 
827+     } 
828+     super ( message ,  options ) ; 
826829    this . code  =  'ABORT_ERR' ; 
827830    this . name  =  'AbortError' ; 
828831  } 
Original file line number Diff line number Diff line change 1+ // Flags: --expose-internals 
2+ 'use strict' ; 
3+ 
4+ require ( '../common' ) ; 
5+ const  { 
6+   strictEqual, 
7+   throws, 
8+ }  =  require ( 'assert' ) ; 
9+ const  {  AbortError }  =  require ( 'internal/errors' ) ; 
10+ 
11+ { 
12+   const  err  =  new  AbortError ( ) ; 
13+   strictEqual ( err . message ,  'The operation was aborted' ) ; 
14+   strictEqual ( err . cause ,  undefined ) ; 
15+ } 
16+ 
17+ { 
18+   const  cause  =  new  Error ( 'boom' ) ; 
19+   const  err  =  new  AbortError ( 'bang' ,  {  cause } ) ; 
20+   strictEqual ( err . message ,  'bang' ) ; 
21+   strictEqual ( err . cause ,  cause ) ; 
22+ } 
23+ 
24+ { 
25+   throws ( ( )  =>  new  AbortError ( '' ,  false ) ,  { 
26+     code : 'ERR_INVALID_ARG_TYPE' 
27+   } ) ; 
28+   throws ( ( )  =>  new  AbortError ( '' ,  '' ) ,  { 
29+     code : 'ERR_INVALID_ARG_TYPE' 
30+   } ) ; 
31+ } 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments