PsrEventDispatcherErrorReporter
in package
implements
ErrorReporterInterface
Read onlyYes
FinalYes
This error reporter implementation MUST dispatch all reported exceptions as events using a PSR-14 compatible event dispatcher.
It SHALL provide a detailed event including the exception, callback description, and arguments. If the dispatcher throws an exception, this class MUST log the failure using error_log and MUST NOT throw further exceptions.
Table of Contents
Interfaces
- ErrorReporterInterface
- This interface MUST be implemented by any class that reports exceptions from deferred callbacks.
Properties
- $dispatcher : EventDispatcherInterface
Methods
- __construct() : mixed
- Constructs a new PsrEventDispatcherErrorReporter instance.
- report() : void
- Reports a throwable by dispatching a DeferredCallbackFailed event.
Properties
$dispatcher
private
EventDispatcherInterface
$dispatcher
Methods
__construct()
Constructs a new PsrEventDispatcherErrorReporter instance.
public
__construct(EventDispatcherInterface $dispatcher) : mixed
Parameters
- $dispatcher : EventDispatcherInterface
-
the PSR-14 event dispatcher to use for error reporting
report()
Reports a throwable by dispatching a DeferredCallbackFailed event.
public
report(Throwable $throwable[, callable|null $callback = null ][, array<string|int, mixed> $args = [] ]) : void
This method MUST dispatch the exception as an event. If the dispatcher fails, the error MUST be logged.
Parameters
- $throwable : Throwable
-
the exception or error to report
- $callback : callable|null = null
-
the related callback, if available
- $args : array<string|int, mixed> = []
-
arguments passed to the callback, if any