for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Jellyfish\Event;
use Closure;
use Exception;
abstract class AbstractEventListener implements EventListenerInterface
{
/**
* @var \Closure|null
*/
protected $errorHandler;
* @param \Closure|null $errorHandler
*
* @return \Jellyfish\Event\EventListenerInterface
public function setErrorHandler(?Closure $errorHandler): EventListenerInterface
$this->errorHandler = $errorHandler;
return $this;
}
* @param \Jellyfish\Event\EventInterface $event
public function handle(EventInterface $event): EventListenerInterface
try {
$this->doHandle($event);
} catch (Exception $e) {
$this->handleError($e, $event);
abstract protected function doHandle(EventInterface $event): EventListenerInterface;
* @param \Exception $e
protected function handleError(Exception $e, EventInterface $event): EventListenerInterface
if ($this->errorHandler === null) {
$this->errorHandler->call($this, $e, $event);