@@ -3,6 +3,8 @@ import { describe, expect, test as it } from "vitest";
33
44import {
55 CLOCK_SKEW_ERROR_CODES ,
6+ NODEJS_NETWORK_ERROR_CODES ,
7+ NODEJS_TIMEOUT_ERROR_CODES ,
68 THROTTLING_ERROR_CODES ,
79 TRANSIENT_ERROR_CODES ,
810 TRANSIENT_ERROR_STATUS_CODES ,
@@ -16,15 +18,17 @@ const checkForErrorType = (
1618 httpStatusCode ?: number ;
1719 $retryable ?: RetryableTrait ;
1820 cause ?: Partial < Error > ;
21+ code ?: string ;
1922 } ,
2023 errorTypeResult : boolean
2124) => {
22- const { name, httpStatusCode, $retryable, cause } = options ;
25+ const { name, httpStatusCode, $retryable, cause, code } = options ;
2326 const error = Object . assign ( new Error ( ) , {
2427 name,
2528 $metadata : { httpStatusCode } ,
2629 $retryable,
2730 cause,
31+ code,
2832 } ) ;
2933 expect ( isErrorTypeFunc ( error as SdkError ) ) . toBe ( errorTypeResult ) ;
3034} ;
@@ -141,6 +145,18 @@ describe("isTransientError", () => {
141145 error . cause = error ;
142146 checkForErrorType ( isTransientError , { cause : error } , false ) ;
143147 } ) ;
148+
149+ NODEJS_TIMEOUT_ERROR_CODES . forEach ( ( code ) => {
150+ it ( `should declare error with cause with the code "${ code } " to be a Transient error` , ( ) => {
151+ checkForErrorType ( isTransientError , { code } , true ) ;
152+ } ) ;
153+ } ) ;
154+
155+ NODEJS_NETWORK_ERROR_CODES . forEach ( ( code ) => {
156+ it ( `should declare error with cause with the code "${ code } " to be a Transient error` , ( ) => {
157+ checkForErrorType ( isTransientError , { code } , true ) ;
158+ } ) ;
159+ } ) ;
144160} ) ;
145161
146162describe ( "isServerError" , ( ) => {
0 commit comments