Error Classes & Type Guards Reference

Technical specifications for error class members, properties, codes, and narrowing functions.


Exported Type Guard Functions

Boolean Type Guard Functions
PropertyTypeDefaultDescription
isFetchNativeError(err)err is FetchNativeError—Returns true if the error is an instance of any FetchNativeError subclass.
isHttpError(err)err is HttpError—Returns true if error was caused by a 4xx or 5xx HTTP response.
isNetworkError(err)err is NetworkError—Returns true if error was caused by socket failure, DNS error, or offline state.
isTimeoutError(err)err is TimeoutError—Returns true if error was caused by the request exceeding its timeout limit.
isCancelError(err)err is CancelError—Returns true if request was cancelled via AbortSignal or cancelPrevious.
isRetryExhaustedError(err)err is RetryExhaustedError—Returns true if all configured retry attempts were exhausted.
isValidationError(err)err is ValidationError—Returns true if response payload failed runtime schema validation.
isCircuitBreakerError(err)err is CircuitBreakerError—Returns true if request was aborted because the circuit breaker is OPEN.
guards.ts
typescript
import {
  isFetchNativeError,
  isHttpError,
  isNetworkError,
  isTimeoutError,
  isCancelError,
  isRetryExhaustedError,
  isValidationError,
  isCircuitBreakerError,
} from 'react-native-fetch-client';

// Example:
if (isHttpError(err)) {
  // TypeScript knows err is HttpError
  console.log(err.status, err.statusText, err.data);
}