CF
Start

Reliability

Error Handling

Handle SDK errors, HTTP status codes, network failures, and retryable requests.

Overview

All official clients raise a language-native SDK error when the API returns a non-2xx response. The error includes a message and status code so your app can handle authentication, validation, throttling, and server failures deliberately.

Error types

JavaScript / TypeScript

CheFuAcademyError

Python

CheFuAcademyError

Go

*chefuacademy.Error

Java

CheFuAcademyException

.NET

CheFuAcademyException

PHP

CheFuAcademyException

Ruby

CheFuAcademy::Error

cURL

HTTP status + response body

Status codes

400

Invalid request or malformed parameters.

401

Missing, invalid, or expired API key or user session.

403

Revoked key or insufficient developer permissions.

404

The course, video, or key was not found.

429

Rate limit exceeded. Retry after waiting.

500

Unexpected CheFu Academy server issue.

Handling failures

Use the SDK error type for your language and branch on status code when your app needs a specific recovery path.

Language example

Catch SDK errors

Keep detailed logs private and show user-friendly messages.

JavaScript / TypeScript

chefu-academy-sdk - npm

error-handling.ts
import { CheFuAcademyError } from 'chefu-academy-sdk';

try {
  return await sdk.courses.getAll({ limit: 12 });
} catch (error) {
  if (error instanceof CheFuAcademyError) {
    if (error.statusCode === 401) {
      throw new Error('Check CHEFU_API_KEY.');
    }

    if (error.statusCode === 429) {
      throw new Error('Too many requests. Retry shortly.');
    }

    throw new Error(error.message);
  }

  throw error;
}

Network errors may not include a status code

Treat errors without a status code as connectivity, DNS, timeout, or local environment problems.

Production guidance

  • Show user-friendly messages and log detailed errors privately.
  • Retry only safe read operations, and use backoff for 429 or transient 5xx errors.

  • Do not log full API keys, passwords, or bearer tokens.
  • Fail closed when authentication or permissions are unclear.