Skip to content

Commit 5368930

Browse files
committed
Update thrown error code to 404.
I overlooked the behat test which fails since I didn't update the error code which is thrown by the exception.
1 parent fbf69f0 commit 5368930

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/Bridge/RamseyUuid/Identifier/Normalizer/UuidNormalizer.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
namespace ApiPlatform\Core\Bridge\RamseyUuid\Identifier\Normalizer;
1515

16+
use ApiPlatform\Core\Exception\InvalidIdentifierException;
1617
use Ramsey\Uuid\Exception\InvalidUuidStringException;
1718
use Ramsey\Uuid\Uuid;
1819
use Ramsey\Uuid\UuidInterface;
19-
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
2020
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
2121

2222
/**
@@ -28,22 +28,20 @@ final class UuidNormalizer implements DenormalizerInterface
2828
{
2929
/**
3030
* {@inheritdoc}
31-
*
32-
* @throws NotNormalizableValueException Occurs when the identifier format is invalid
3331
*/
3432
public function denormalize($data, $class, $format = null, array $context = [])
3533
{
3634
try {
3735
return Uuid::fromString($data);
3836
} catch (InvalidUuidStringException $e) {
39-
throw new NotNormalizableValueException('Not found, because of an invalid identifier format', $e->getCode(), $e);
37+
throw new InvalidIdentifierException($e->getMessage(), $e->getCode(), $e);
4038
}
4139
}
4240

4341
/**
4442
* {@inheritdoc}
4543
*/
46-
public function supportsDenormalization($data, $type, $format = null): bool
44+
public function supportsDenormalization($data, $type, $format = null)
4745
{
4846
return is_a($type, UuidInterface::class, true);
4947
}

src/EventListener/ReadListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function onKernelRequest(GetResponseEvent $event): void
109109
$data = $this->getSubresourceData($identifiers, $attributes, $context);
110110
}
111111
} catch (InvalidIdentifierException $e) {
112-
throw new NotFoundHttpException('Not found, because of an invalid identifier configuration', $e);
112+
throw new NotFoundHttpException('Invalid identifier value or configuration.', $e);
113113
}
114114

115115
if (null === $data) {

tests/Bridge/RamseyUuid/Normalizer/UuidNormalizerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
namespace ApiPlatform\Core\Tests\Bridge\RamseyUuid\Normalizer;
1515

1616
use ApiPlatform\Core\Bridge\RamseyUuid\Identifier\Normalizer\UuidNormalizer;
17+
use ApiPlatform\Core\Exception\InvalidIdentifierException;
1718
use PHPUnit\Framework\TestCase;
1819
use Ramsey\Uuid\Uuid;
19-
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
2020

2121
class UuidNormalizerTest extends TestCase
2222
{
@@ -37,7 +37,7 @@ public function testNoSupportDenormalizeUuid()
3737

3838
public function testFailDenormalizeUuid()
3939
{
40-
$this->expectException(NotNormalizableValueException::class);
40+
$this->expectException(InvalidIdentifierException::class);
4141

4242
$uuid = 'notanuuid';
4343
$normalizer = new UuidNormalizer();

0 commit comments

Comments
 (0)