File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -523,7 +523,7 @@ exports.thrownAt = function (error) {
523
523
error = error || new Error ( ) ;
524
524
const stack = typeof error . stack === 'string' ? error . stack : '' ;
525
525
const frame = stack . replace ( error . toString ( ) , '' ) . split ( '\n' ) . slice ( 1 ) . filter ( internals . filterLocal ) [ 0 ] || '' ;
526
- const at = frame . match ( / ^ \s * a t [ ^ ( ] * \( ? ( .+ ) \: ( \d + ) \: ( \d + ) \) ? $ / ) ;
526
+ const at = frame . match ( / ^ \s * a t [ ^ ( / ] * \( ? ( .+ ) \: ( \d + ) \: ( \d + ) \) ? $ / ) ;
527
527
return Array . isArray ( at ) ? {
528
528
filename : at [ 1 ] ,
529
529
line : at [ 2 ] ,
Original file line number Diff line number Diff line change @@ -2424,4 +2424,25 @@ describe('thrownAt()', () => {
2424
2424
2425
2425
Hoek . assert ( at === undefined , 'Reports the wrong at information' ) ;
2426
2426
} ) ;
2427
+
2428
+ it ( 'handles error with unnamed functions' , ( ) => {
2429
+
2430
+ const test = ( f ) => f ( ) ;
2431
+
2432
+ try {
2433
+
2434
+ // eslint-disable-next-line prefer-arrow-callback
2435
+ test ( function ( ) {
2436
+
2437
+ Code . expect ( true ) . to . be . false ( ) ;
2438
+ } ) ;
2439
+
2440
+ Code . fail ( 'an error should have been thrown' ) ;
2441
+ }
2442
+ catch ( ex ) {
2443
+
2444
+ const at = Code . thrownAt ( ex ) ;
2445
+ Hoek . assert ( at . filename === __filename ) ;
2446
+ }
2447
+ } ) ;
2427
2448
} ) ;
You can’t perform that action at this time.
0 commit comments