Skip to content

Commit

Permalink
Allow callable to be pass as error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime-rainville committed Dec 12, 2024
1 parent 3a87027 commit 019038f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/AsyncEventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ class AsyncEventDispatcher implements EventDispatcherInterface

/**
* @param ListenerProviderInterface $listenerProvider The provider of event listeners
* @param Closure(Throwable): (void) $errorHandler The handler for errors thrown by listeners
* @param callable(Throwable): (void) $errorHandler The handler for errors thrown by listeners
*/
public function __construct(
private readonly ListenerProviderInterface $listenerProvider,
?Closure $errorHandler = null
?callable $errorHandler = null
) {
if ($errorHandler === null) {
$this->errorHandler = function (Throwable $exception): void {};
} else {
$this->errorHandler = $errorHandler;
$this->errorHandler = Closure::fromCallable($errorHandler);
}
}

Expand Down

0 comments on commit 019038f

Please sign in to comment.