Skip to main content
function isApiError(error: unknown): error is APIError;
Type guard to check if the error is an API error.

Parameters

ParameterTypeDescription
errorunknownThe error to check.

Returns

error is APIError
  • True if the error is an API error, false otherwise.

Example

try {
  ...
}
catch (error) {
  if (isApiError(error)) {
    // Handle API error
    console.log(error.errorMessage);
  }
}