PairException - viames/pair GitHub Wiki

Pair framework: PairException

Pair\Exceptions\PairException is the base framework exception type.

Constructor behavior

__construct(string $message, int $code = 0, ?Throwable $previous = null):

  • logs tracked message through Logger
  • escalates to CriticalException for critical error codes (DB connection/config/missing DB objects)

Front-end notification helper

PairException::frontEnd(string $message): void

Behavior:

  • in production, message is replaced with translated generic error text
  • in headless mode -> JSON error response
  • in web mode -> modal error notification

Implementation example

throw new \Pair\Exceptions\PairException('Invalid state', \Pair\Exceptions\ErrorCodes::GENERIC_ERROR);

Notes

Many framework exceptions extend this class and inherit logging/escalation semantics.

See also: AppException, CriticalException, ApiException, AjaxException.