From 15d063b6f767a7b02ef0ca1f3c568ee120d2f1de Mon Sep 17 00:00:00 2001 From: Andrew Moore Date: Wed, 27 Nov 2013 14:35:15 -0500 Subject: [PATCH] Create ExceptionHandlerInterface to allow third party exception handlers' to handle fatal errors --- src/Symfony/Component/Debug/ErrorHandler.php | 6 ++--- .../Component/Debug/ExceptionHandler.php | 6 ++--- .../Debug/ExceptionHandlerInterface.php | 27 +++++++++++++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 src/Symfony/Component/Debug/ExceptionHandlerInterface.php diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 318c6716e256d..e72e249f7fce7 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -155,7 +155,7 @@ function ($row) { $exceptionHandler = set_exception_handler('var_dump'); restore_exception_handler(); - if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandler) { + if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandlerInterface) { if (self::$stackedErrorLevels) { self::$stackedErrors[] = func_get_args(); @@ -263,7 +263,7 @@ public function handleFatal() $exceptionHandler = set_exception_handler('var_dump'); restore_exception_handler(); - if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandler) { + if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandlerInterface) { $this->handleFatalError($exceptionHandler[0], $error); } } @@ -284,7 +284,7 @@ protected function getFatalErrorHandlers() ); } - private function handleFatalError(ExceptionHandler $exceptionHandler, array $error) + private function handleFatalError(ExceptionHandlerInterface $exceptionHandler, array $error) { $level = isset($this->levels[$error['type']]) ? $this->levels[$error['type']] : $error['type']; $message = sprintf('%s: %s in %s line %d', $level, $error['message'], $error['file'], $error['line']); diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index cd781b5609774..87e260dab180a 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -29,7 +29,7 @@ * * @author Fabien Potencier */ -class ExceptionHandler +class ExceptionHandler implements ExceptionHandlerInterface { private $debug; private $charset; @@ -57,14 +57,14 @@ public static function register($debug = true) } /** + * {@inheritDoc} + * * Sends a response for the given Exception. * * If you have the Symfony HttpFoundation component installed, * this method will use it to create and send the response. If not, * it will fallback to plain PHP functions. * - * @param \Exception $exception An \Exception instance - * * @see sendPhpResponse * @see createResponse */ diff --git a/src/Symfony/Component/Debug/ExceptionHandlerInterface.php b/src/Symfony/Component/Debug/ExceptionHandlerInterface.php new file mode 100644 index 0000000000000..5ebefcf829e3f --- /dev/null +++ b/src/Symfony/Component/Debug/ExceptionHandlerInterface.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug; + +/** + * An ExceptionHandler does something useful with an exception. + * + * @author Andrew Moore + */ +interface ExceptionHandlerInterface +{ + /** + * Handles an exception. + * + * @param \Exception $exception An \Exception instance + */ + public function handle(\Exception $exception); +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy