CriticalException - viames/pair GitHub Wiki
Pair framework: CriticalException
Pair\Exceptions\CriticalException handles fatal framework/application failures.
Constructor behavior
__construct(string $message, int $code = 0, ?Throwable $previous = null):
- logs emergency-level error
- terminates app through
CriticalException::terminate(...)
Termination flow
terminate(string $message, int $code = 0): void
- sets HTTP 500
- disables logger for env-file loading failures
- in headless mode: stops without rendering HTML
- in web mode: clears buffer, resolves fallback template, renders via
TemplateRenderer
Fallback template resolution
Internal fallback search in templates:
500.phpdefault.php
If no template exists, execution stops with fatal message.
Implementation example
use Pair\Exceptions\CriticalException;
use Pair\Exceptions\ErrorCodes;
throw new CriticalException('Configuration file missing', ErrorCodes::LOADING_ENV_FILE);
See also: PairException, TemplateRenderer, ErrorCodes.