AjaxException - viames/pair GitHub Wiki
Pair framework: AjaxException
Pair\Exceptions\AjaxException is specialized for AJAX request failures with JSON replies.
Constructor behavior
__construct(string $message, int $code = 0, ?Throwable $previous = null):
- logs error message
- preserves base exception behavior from
PairException
Static reply helper
AjaxException::reply(string $message, ?int $code = null, int $httpCode = 400): void
- in production, replaces message with translated generic message
- sends JSON error payload
Implementation example
use Pair\Exceptions\AjaxException;
if (!$isValidRequest) {
AjaxException::reply('Invalid request payload', 2001, 422);
}
See also: ApiException, PairException, Controller.