Created
July 22, 2016 06:04
-
-
Save crmpicco/1b12168060a33ceed8af946307604169 to your computer and use it in GitHub Desktop.
An exception listener to pickup PDOExceptions thrown in the codebase.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* An exception listener to pickup PDOExceptions thrown in the codebase. | |
* | |
* @author Craig R Morton <crmpicco@aol.com> | |
* @date 22-07-2016 | |
*/ | |
namespace AppBundle\EventListener; | |
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; | |
class PdoExceptionListener | |
{ | |
/** | |
* @param GetResponseForExceptionEvent $event | |
*/ | |
public function onPdoException(GetResponseForExceptionEvent $event) | |
{ | |
$exception = $event->getException(); | |
if ($exception instanceof \PDOException) { | |
error_log('We caught a PDOException, please see below for a stacktrace'); | |
error_log($exception->getTraceAsString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment