Skip to content

Commit 2df7d95

Browse files
committed
bug #2263 Allow to specify Throwable as exception class (a-menshchikov)
This PR was merged into the 2.x branch. Discussion ---------- Allow to specify Throwable as exception class Currently we can't use Throwable in exception.codes because check method uses `is_subclass_of`. This PR fixes this issue. Commits ------- a1c9138 Allow to specify Throwable as exception class
2 parents 88470cc + a1c9138 commit 2df7d95

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ private function addExceptionSection(ArrayNodeDefinition $rootNode)
561561

562562
private function testExceptionExists(string $throwable)
563563
{
564-
if (!is_subclass_of($throwable, \Throwable::class)) {
564+
if (!is_a($throwable, \Throwable::class, true)) {
565565
throw new InvalidConfigurationException(sprintf('FOSRestBundle exception mapper: Could not load class "%s" or the class does not extend from "%s". Most probably this is a configuration problem.', $throwable, \Throwable::class));
566566
}
567567
}

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function testExceptionCodesAcceptsIntegers()
4848
$expectedConfig = [
4949
\RuntimeException::class => 500,
5050
\TypeError::class => 500,
51+
\Throwable::class => 500,
5152
];
5253

5354
$config = $this->processor->processConfiguration(

0 commit comments

Comments
 (0)