Skip to content

Instantly share code, notes, and snippets.

@crmpicco
Created July 22, 2016 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crmpicco/1b12168060a33ceed8af946307604169 to your computer and use it in GitHub Desktop.
Save crmpicco/1b12168060a33ceed8af946307604169 to your computer and use it in GitHub Desktop.
An exception listener to pickup PDOExceptions thrown in the codebase.
<?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