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 0fd9ef3

Browse filesBrowse files
committed
Debug: catch Throwable
1 parent 8320687 commit 0fd9ef3
Copy full SHA for 0fd9ef3

File tree

5 files changed

+28
-5
lines changed
Filter options

5 files changed

+28
-5
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/ErrorHandler.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,8 @@ public static function handleFatalError(array $error = null)
629629
}
630630
} catch (\Exception $exception) {
631631
// Handled below
632+
} catch (\Throwable $exception) {
633+
// Handled below
632634
}
633635

634636
if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/ExceptionHandler.php
+11-2Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ public function handle(\Exception $exception)
144144
// All handlers failed. Let PHP handle that now.
145145
throw $exception;
146146
}
147+
} catch (\Throwable $e) {
148+
if (!$caughtLength) {
149+
// All handlers failed. Let PHP handle that now.
150+
throw $exception;
151+
}
147152
}
148153
}
149154

@@ -285,10 +290,14 @@ public function getContent(FlattenException $exception)
285290

286291
$content .= " </ol>\n</div>\n";
287292
}
288-
} catch (\Exception $e) {
293+
} catch (\Exception $renderingException) {
294+
} catch (\Throwable $renderingException) {
295+
}
296+
297+
if (isset($renderingException)) {
289298
// something nasty happened and we cannot throw an exception anymore
290299
if ($this->debug) {
291-
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $this->escapeHtml($e->getMessage()));
300+
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($renderingException), $this->escapeHtml($renderingException->getMessage()));
292301
} else {
293302
$title = 'Whoops, looks like something went wrong.';
294303
}

‎src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ class ChildTestingStacking extends TestingStacking { function foo($bar) {} }
122122
restore_error_handler();
123123
restore_exception_handler();
124124

125+
throw $exception;
126+
} catch (\Throwable $exception) {
127+
restore_error_handler();
128+
restore_exception_handler();
129+
125130
throw $exception;
126131
}
127132
}

‎src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ public function testConstruct()
132132
restore_error_handler();
133133
restore_exception_handler();
134134

135+
throw $e;
136+
} catch (\Throwable $e) {
137+
restore_error_handler();
138+
restore_exception_handler();
139+
135140
throw $e;
136141
}
137142
}

‎src/Symfony/Component/Debug/Tests/Fixtures/ToStringThrower.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/Tests/Fixtures/ToStringThrower.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ public function __toString()
1616
try {
1717
throw $this->exception;
1818
} catch (\Exception $e) {
19-
// Using user_error() here is on purpose so we do not forget
20-
// that this alias also should work alongside with trigger_error().
21-
return user_error($e, E_USER_ERROR);
19+
} catch (\Throwable $e) {
2220
}
21+
22+
// Using user_error() here is on purpose so we do not forget
23+
// that this alias also should work alongside with trigger_error().
24+
return user_error($e, E_USER_ERROR);
2325
}
2426
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.