Skip to content

Psr3ErrorHandler

  • Full name: \Qubus\Error\Handlers\Psr3ErrorHandler
  • This class is marked as final and can't be subclassed
  • This class implements: \Qubus\Error\Handlers\ErrorHandler
  • This class is a Final class

Constants

Constant Visibility Type Value
DEFAULT_ERROR_LEVEL_MAP private [\ParseError::class => \Psr\Log\LogLevel::CRITICAL, \Throwable::class => \Psr\Log\LogLevel::ERROR]
DEFAULT_LOG_LEVEL private \Psr\Log\LogLevel::ERROR
ERROR_KEY public 'error'

Properties

logger

private \Psr\Log\LoggerInterface $logger

levelMap

Defines which error levels should be mapped to certain error types.

private array $levelMap

Note: The errors are checked in order, so if you want to define fallbacks for classes higher in the tree make sure to add them to the end of the map.


ignoreSeverity

Ignores the severity when detecting the log level.

private bool $ignoreSeverity

allowNonPsrLevels

Enables the handler to accept detecting non-PSR-3 log levels.

private bool $allowNonPsrLevels

Note: when detecting an invalid level the handler will silently fall back to the default.


Methods

__construct

public __construct(\Psr\Log\LoggerInterface $logger, array $levelMap = []): mixed

Parameters:

Parameter Type Description
$logger \Psr\Log\LoggerInterface
$levelMap array

ignoreSeverity

Ignores the severity when detecting the log level.

public ignoreSeverity(bool $ignoreSeverity = true): void

Parameters:

Parameter Type Description
$ignoreSeverity bool

allowNonPsrLevels

Enables the handler to accept detecting non-PSR-3 log levels.

public allowNonPsrLevels(bool $allowNonPsrLevels = true): void

Parameters:

Parameter Type Description
$allowNonPsrLevels bool

handle

public handle(\Throwable $t, array $context = []): void

Parameters:

Parameter Type Description
$t \Throwable
$context array

getLevel

Determines the level for the error.

private getLevel(\Throwable $t, array $context): string

Parameters:

Parameter Type Description
$t \Throwable
$context array

checkLevel

Checks whether a log level exists.

private checkLevel(string $level): bool

Parameters:

Parameter Type Description
$level string

validateLevel

Validates whether a log level exists (if non-PSR levels are not allowed).

private validateLevel(string $level): bool

Parameters:

Parameter Type Description
$level string

getType

Determines the error type.

private getType(\Throwable $t): string

Parameters:

Parameter Type Description
$t \Throwable


Automatically generated on 2025-10-13