Skip to content

Commit eeae733

Browse files
committed
Debug: catch Throwable
1 parent 82a766e commit eeae733

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

src/Symfony/Component/Debug/ErrorHandler.php

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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)
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