Skip to content

Commit

Permalink
Throw UnexpectedValueException when value is not valid (api-platform#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrixx authored Aug 17, 2021
1 parent fec6fd8 commit ccc297b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Core/Serializer/AbstractItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ protected function validateType(string $attribute, Type $type, $value, string $f
}

if (!$isValid) {
throw new InvalidArgumentException(sprintf('The type of the "%s" attribute must be "%s", "%s" given.', $attribute, $builtinType, \gettype($value)));
throw new UnexpectedValueException(sprintf('The type of the "%s" attribute must be "%s", "%s" given.', $attribute, $builtinType, \gettype($value)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Serializer/AbstractItemNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ public function testInnerDocumentNotAllowed()

public function testBadType()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(UnexpectedValueException::class);
$this->expectExceptionMessage('The type of the "foo" attribute must be "float", "integer" given.');

$data = [
Expand Down

0 comments on commit ccc297b

Please sign in to comment.