Skip to content

Commit a3c6d56

Browse files
authored
fix(symfony): provider can throw validation exception (#5586)
fixes #5585
1 parent 271adf0 commit a3c6d56

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

CallableProvider.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
namespace ApiPlatform\State;
1515

16-
use ApiPlatform\Exception\RuntimeException;
1716
use ApiPlatform\Metadata\Operation;
17+
use ApiPlatform\State\Exception\ProviderNotFoundException;
1818
use Psr\Container\ContainerInterface;
1919

2020
final class CallableProvider implements ProviderInterface
@@ -34,7 +34,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
3434

3535
if (\is_string($provider)) {
3636
if (!$this->locator->has($provider)) {
37-
throw new RuntimeException(sprintf('Provider "%s" not found on operation "%s"', $provider, $operation->getName()));
37+
throw new ProviderNotFoundException(sprintf('Provider "%s" not found on operation "%s"', $provider, $operation->getName()));
3838
}
3939

4040
/** @var ProviderInterface $providerInstance */
@@ -43,6 +43,6 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
4343
return $providerInstance->provide($operation, $uriVariables, $context);
4444
}
4545

46-
throw new RuntimeException(sprintf('Provider not found on operation "%s"', $operation->getName()));
46+
throw new ProviderNotFoundException(sprintf('Provider not found on operation "%s"', $operation->getName()));
4747
}
4848
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
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+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\State\Exception;
15+
16+
use ApiPlatform\Metadata\Exception\RuntimeException;
17+
18+
final class ProviderNotFoundException extends RuntimeException
19+
{
20+
}

0 commit comments

Comments
 (0)