Skip to content

ErrorCodes

Viames Marino edited this page Apr 25, 2026 · 3 revisions

Pair framework: ErrorCodes

Pair\Exceptions\ErrorCodes contains framework error code constants used across exceptions and logs.

How to use

Use constants when throwing Pair exceptions so logs and handling rules are consistent.

use Pair\Exceptions\ErrorCodes;
use Pair\Exceptions\PairException;

throw new PairException('DB query failed', ErrorCodes::DB_QUERY_FAILED);

Why it matters

Some codes are treated as critical and can escalate to CriticalException.

This keeps error-handling behavior deterministic across framework layers.

Recommended pattern

  • choose the most specific code available
  • avoid magic numbers in throws/replies
  • keep application-specific codes separate from framework-level constants

Integration-specific constants include errors such as STRIPE_ERROR, GOOGLE_MAPS_ERROR, WHATSAPP_ERROR, OPENAI_ERROR, GEMINI_ERROR, CLAUDE_ERROR, RESEND_ERROR, CLOUDFLARE_TURNSTILE_ERROR, MEILISEARCH_ERROR, SENTRY_ERROR, OPENTELEMETRY_ERROR, and SUPABASE_ERROR.

See also: PairException, CriticalException, AppException, ApiException.

Clone this wiki locally