Skip to content

ErrorCodes

Viames Marino edited this page Feb 23, 2026 · 1 revision

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

See also: PairException, CriticalException, AppException, ApiException.

Clone this wiki locally