jalismrs/symfony.bundle.event.exception

Adds an exception event with its listener

1.1.1 2021-03-04 10:49 UTC

This package is auto-updated.

Last update: 2024-05-04 17:51:59 UTC


README

Adds an exception event with its listener

Test

phpunit or vendor/bin/phpunit

coverage reports will be available in var/coverage

Use

EventListener is assumed to be active and configured

use Jalismrs\Symfony\Bundle\JalismrsExceptionEventBundle\Event\ExceptionEvent;
use Symfony\Component\EventDispatcher\EventDispatcher;

class SomeClass {
    private EventDispatcher $eventDispatcher;

    public function someFunction(): void {
        try {
            // do something
        } catch(Exception $exception) {
            $exceptionEvent = new ExceptionEvent(
                $exception
            );
            $this->eventDispatcher->dispatch($exceptionEvent);
        }
    }
}