8000 Create ExceptionHandlerInterface to allow third party exception handl… · symfony/symfony@15d063b · GitHub
[go: up one dir, main page]

Skip to content

Commit 15d063b

Browse files
committed
Create ExceptionHandlerInterface to allow third party exception handlers' to handle fatal errors
1 parent 7baeaa2 commit 15d063b

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function ($row) {
155155
$exceptionHandler = set_exception_handler('var_dump');
156156
restore_exception_handler();
157157

158-
if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandler) {
158+
if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandlerInterface) {
159159
if (self::$stackedErrorLevels) {
160160
self::$stackedErrors[] = func_get_args();
161161

@@ -263,7 +263,7 @@ public function handleFatal()
263263
$exceptionHandler = set_exception_handler('var_dump');
264264
restore_exception_handler();
265265

266-
if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandler) {
266+
if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandlerInterface) {
267267
$this->handleFatalError($exceptionHandler[0], $error);
268268
}
269269
}
@@ -284,7 +284,7 @@ protected function getFatalErrorHandlers()
284284
);
285285
}
286286

287-
private function handleFatalError(ExceptionHandler $exceptionHandler, array $error)
287+
private function handleFatalError(ExceptionHandlerInterface $exceptionHandler, array $error)
288288
{
289289
$level = isset($this->levels[$error['type']]) ? $this->levels[$error['type']] : $error['type'];
290290
$message = sprintf('%s: %s in %s line %d', $level, $error['message'], $error['file'], $error['line']);

src/Symfony/Component/Debug/ExceptionHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*
3030
* @author Fabien Potencier <fabien@symfony.com>
3131
*/
32-
class ExceptionHandler
32+
class ExceptionHandler implements ExceptionHandlerInterface
3333
{
3434
private $debug;
3535
private $charset;
@@ -57,14 +57,14 @@ public static function register($debug = true)
5757
}
5858

5959
/**
60+
* {@inheritDoc}
61+
*
6062
* Sends a response for the given Exception.
6163
*
6264
* If you have the Symfony HttpFoundation component installed,
6365
* this method will use it to create and send the response. If not,
6466
* it will fallback to plain PHP functions.
6567
*
66-
* @param \Exception $exception An \Exception instance
67-
*
6868
* @see sendPhpResponse
6969
* @see createResponse
7070
*/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Debug;
13+
14+
/**
15+
* An ExceptionHandler does something useful with an exception.
16+
*
17+
* @author Andrew Moore <me@andrewmoore.ca>
18+
*/
19+
interface ExceptionHandlerInterface
20+
{
21+
/**
22+
* Handles an exception.
23+
*
24+
* @param \Exception $exception An \Exception instance
25+
*/
26+
public function handle(\Exception $exception);
27+
}

0 commit comments

Comments
 (0)
0