Skip to content

Commit 11e6c48

Browse files
Merge branch '2.6' into 2.7
* 2.6: [Form] NativeRequestHandler file handling fix [VarDumper] Workaround stringy numeric keys [HttpKernel] Throw double-bounce exceptions minor #13377 [Console] Change greater by greater or equal for isFresh in FileResource [2.3] [HttpFoundation] fixed param order for Nginx's x-accel-redirect
2 parents 42f56fc + fb71708 commit 11e6c48

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

EventListener/ExceptionListener.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ public function onKernelException(GetResponseForExceptionEvent $event)
5757
try {
5858
$response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, true);
5959
} catch (\Exception $e) {
60-
$this->logException($exception, sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage()), false);
60+
$this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), false);
6161

6262
// set handling to false otherwise it wont be able to handle further more
6363
$handling = false;
6464

65-
// re-throw the exception from within HttpKernel as this is a catch-all
66-
return;
65+
// throwing $e, not $exception, is on purpose: fixing error handling code paths is the most important
66+
throw $e;
6767
}
6868

6969
$event->setResponse($response);
@@ -81,7 +81,7 @@ public static function getSubscribedEvents()
8181
/**
8282
* Logs an exception.
8383
*
84-
* @param \Exception $exception The original \Exception instance
84+
* @param \Exception $exception The \Exception instance
8585
* @param string $message The error message to log
8686
* @param bool $original False when the handling of the exception thrown another exception
8787
*/

Tests/EventListener/ExceptionListenerTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ public function testHandleWithoutLogger($event, $event2)
5454

5555
try {
5656
$l->onKernelException($event2);
57-
} catch (\Exception $e) {
58-
$this->assertSame('foo', $e->getMessage());
57+
$this->fail('RuntimeException expected');
58+
} catch (\RuntimeException $e) {
59+
$this->assertSame('bar', $e->getMessage());
5960
}
6061
}
6162

@@ -73,8 +74,9 @@ public function testHandleWithLogger($event, $event2)
7374

7475
try {
7576
$l->onKernelException($event2);
76-
} catch (\Exception $e) {
77-
$this->assertSame('foo', $e->getMessage());
77+
$this->fail('RuntimeException expected');
78+
} catch (\RuntimeException $e) {
79+
$this->assertSame('bar', $e->getMessage());
7880
}
7981

8082
$this->assertEquals(3, $logger->countErrors());
@@ -137,6 +139,6 @@ class TestKernelThatThrowsException implements HttpKernelInterface
137139
{
138140
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
139141
{
140-
throw new \Exception('bar');
142+
throw new \RuntimeException('bar');
141143
}
142144
}

0 commit comments

Comments
 (0)