Skip to content

Commit 3fe5f23

Browse files
committed
Revert thrown exception back to InvalidIdentifierException.
As discussed in PR #3132, the thrown exception should stay as InvalidIdentifierException only the error message should be clarified.
1 parent 2574ee2 commit 3fe5f23

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
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', 404, $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
}

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)