@@ -1458,52 +1458,20 @@ function formatRetryError(
14581458) : Error {
14591459 const parts : string [ ] = [ ] ;
14601460
1461- if ( resp . status !== undefined && ! isNaN ( resp . status ) ) {
1461+ if ( typeof resp . status === 'number' && ! isNaN ( resp . status ) ) {
14621462 parts . push ( `status: ${ resp . status } ` ) ;
14631463 }
14641464
14651465 const err = resp . data ;
14661466 if ( err !== undefined && err !== null ) {
1467- if ( err instanceof Error ) {
1468- const gaxiosErr = err as GaxiosError ;
1469- const errParts : string [ ] = [ ] ;
1470- if ( gaxiosErr . message ) {
1471- errParts . push ( gaxiosErr . message ) ;
1472- }
1473- const status = gaxiosErr . status ?? gaxiosErr . response ?. status ;
1474- if ( status !== undefined && ! isNaN ( status ) && status !== resp . status ) {
1475- errParts . push ( `status: ${ status } ` ) ;
1476- }
1477- const statusText = gaxiosErr . response ?. statusText ;
1478- if ( statusText ) {
1479- errParts . push ( `statusText: ${ statusText } ` ) ;
1480- }
1481- const responseData = gaxiosErr . response ?. data ;
1482- if ( responseData !== undefined && responseData !== null && responseData !== '' ) {
1483- errParts . push (
1484- `response: ${
1485- typeof responseData === 'object'
1486- ? JSON . stringify ( responseData )
1487- : responseData
1488- } `,
1489- ) ;
1490- }
1491- if ( gaxiosErr . code ) {
1492- errParts . push ( `code: ${ gaxiosErr . code } ` ) ;
1493- }
1494- if ( errParts . length > 0 ) {
1495- parts . push ( ...errParts ) ;
1496- } else {
1497- parts . push ( gaxiosErr . toString ( ) || gaxiosErr . name || 'Unknown Error' ) ;
1498- }
1499- } else if ( typeof err === 'object' ) {
1500- const errParts : string [ ] = [ ] ;
1467+ if ( typeof err === 'object' ) {
15011468 const gaxiosErrLike = err as any ;
1469+ const errParts : string [ ] = [ ] ;
15021470 if ( gaxiosErrLike . message ) {
15031471 errParts . push ( String ( gaxiosErrLike . message ) ) ;
15041472 }
15051473 const status = gaxiosErrLike . status ?? gaxiosErrLike . response ?. status ;
1506- if ( status !== undefined && ! isNaN ( status ) && status !== resp . status ) {
1474+ if ( typeof status === 'number' && ! isNaN ( status ) && status !== resp . status ) {
15071475 errParts . push ( `status: ${ status } ` ) ;
15081476 }
15091477 const statusText = gaxiosErrLike . response ?. statusText ;
@@ -1526,6 +1494,8 @@ function formatRetryError(
15261494
15271495 if ( errParts . length > 0 ) {
15281496 parts . push ( ...errParts ) ;
1497+ } else if ( err instanceof Error ) {
1498+ parts . push ( err . toString ( ) || err . name || 'Unknown Error' ) ;
15291499 } else {
15301500 const stringified = JSON . stringify ( err ) ;
15311501 if ( stringified && stringified !== '{}' ) {
0 commit comments