Created
September 13, 2013 03:59
-
-
Save merk/6546649 to your computer and use it in GitHub Desktop.
Disable 404 errors
This file contains hidden or 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 | |
/** | |
* This file is part of IBMS | |
* | |
* (c) Infinite Networks Pty Ltd <http://www.infinite.net.au> | |
* | |
* For the full copyright and license information, please view the LICENSE | |
* file that was distributed with this source code. | |
*/ | |
namespace Ibms\Helper; | |
use Symfony\Component\HttpKernel\EventListener\ExceptionListener; | |
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; | |
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |
class TwigExceptionListener extends ExceptionListener | |
{ | |
/** | |
* Logs an exception. | |
* | |
* @param \Exception $exception The original \Exception instance | |
* @param string $message The error message to log | |
* @param Boolean $original False when the handling of the exception thrown another exception | |
*/ | |
protected function logException(\Exception $exception, $message, $original = true) | |
{ | |
$isCritical = !$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500; | |
if (null !== $this->logger) { | |
if ($isCritical) { | |
$this->logger->critical($message); | |
} else { | |
if ($exception instanceof NotFoundHttpException) { | |
$this->logger->info($message); | |
} else { | |
$this->logger->error($message); | |
} | |
} | |
} elseif (!$original || $isCritical) { | |
error_log($message); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment