Alokai
You are reading the documentation for legacy, which is no longer the latest version. Switch to connect v2

isSpecificSdkHttpError

Checks if the given error was caused by SDKError and matches a specific status code or condition.

Signature

isSpecificSdkHttpError: (
	error: unknown,
	statusCodePredicate: SdkErrorPredicate
) => error is ErrorCausedBySDKError

Parameters

NameRequiredTypeDescription
errorRequiredunknownThe error to check.
statusCodePredicateRequiredSdkErrorPredicateThe predicate to match the error's status code against.

Returns

A type predicate indicating whether the error matches the specific condition.

Referenced Types

Examples

catch (error) {
  if (isSpecificSdkError(error, { statusCode: 422 })) {
    // handle 422
  }
}
catch (error) {
  if (isSpecificSdkError(error, { statusCode: (code) => code === 401 || code === 403 })) {
    // handle 401 or 403
  }
}

On this page