Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 681f14b

Browse filesBrowse files
committed
feature #10353 [Debug] ExceptionHandlerInterface to allow third party exception handlers to handle fatal errors caught by ErrorHandler (FineWolf)
This PR was merged into the 2.5-dev branch. Discussion ---------- [Debug] ExceptionHandlerInterface to allow third party exception handlers to handle fatal errors caught by ErrorHandler | Q | A | ------------- | --- | Bug fix? | yes (other project) | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | Related tickets | schmittjoh/JMSDebuggingBundle#68 | License | MIT | Doc PR | The current `ErrorHandler` is extremely strict on how it selects whether to run an `ExceptionHandler` when an `E_FATAL` occurs. This modification allows any class that implements `ExceptionHandlerInterface` to handle a `FatalErrorException` created by the `ErrorHandler`. Commits ------- 15d063b Create ExceptionHandlerInterface to allow third party exception handlers' to handle fatal errors
2 parents 7baeaa2 + 15d063b commit 681f14b
Copy full SHA for 681f14b

File tree

Expand file treeCollapse file tree

3 files changed

+33
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+33
-6
lines changed
Open diff view settings
Collapse file

‎src/Symfony/Component/Debug/ErrorHandler.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/ErrorHandler.php
+3-3Lines 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']);
Collapse file

‎src/Symfony/Component/Debug/ExceptionHandler.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/ExceptionHandler.php
+3-3Lines 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
*/
Collapse file
+27Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.