Skip to main content
The Proofly SDK simplifies error handling by throwing typed error objects. When an API error occurs, the SDK throws an error that includes the status code and message.

SDK Errors

SDK errors follow this structure:
interface ProoflyError extends Error {
  status: number; // HTTP status code (e.g., 400, 401, 429)
  message: string; // Human-readable error message
  code?: string; // Optional error code string
}

Common Status Codes

400 Bad Request

The request was invalid. Common causes:
  • Missing required parameters
  • Invalid parameter types or formats
  • Parameter validation failures
How to fix:
  • Check that all required fields are provided
  • Verify parameter types match the TypeScript definitions
  • Review validation rules for each field

401 Unauthorized

Authentication failed. Common causes:
  • Missing API key
  • Invalid API key
How to fix:
  • Verify your API key is passed correctly to the PlankProofly constructor.

404 Not Found

The requested resource was not found. How to fix:
  • Verify identifiers (like job IDs) are correct.

429 Too Many Requests

Rate limit exceeded. You’ve made too many requests in a short period. How to fix:
  • Implement exponential backoff in your retry logic
  • Consider upgrading your plan for higher rate limits

API vs Job Errors

There are two types of errors you might encounter:
  1. Request Errors: Thrown immediately when you call a method (e.g., 400 Bad Request, 401 Unauthorized).
  2. Job Errors: Occur during asynchronous processing. The SDK throws these as well if the job ends in a failed status.

Example Error Handling

import { PlankProofly } from '@plank-proofly/api';

const client = new PlankProofly({ apiKey: '...' });

async function performSearch() {
  try {
    const result = await client.profiles.search({...});
    // Success
  } catch (error) {
    if (error.status === 400) {
      console.error('Invalid search parameters:', error.message);
    } else if (error.status === 429) {
      console.error('Rate limit exceeded. Please wait.');
    } else {
      console.error('An unexpected error occurred:', error);
    }
  }
}

Error Handling Best Practices

Always wrap SDK calls in try/catch blocks to handle potential errors.
Implement specific handling for 429 (Rate Limit) and 401 (Auth) errors.
Log the error message and status code for debugging purposes.
Show friendly error messages to your users based on the error type, rather than raw internal error messages.