Browse files

merged branch romainneutron/DependencyInjectionExceptions (PR #5399)


f2e4802 [Yaml] Normalize exceptions
b0f5f2e [Serializer] Normalize exceptions
bcd8db2 [DependencyInjection] Normalize exceptions


Normalize exceptions

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

This PR adds consistence to components which already have their own exception interface.

DependencyInjection, Serializer and Yaml now only throw their own scoped exceptions.

For other components, it's much more work and could introduce some bugs. It would be better to do it in Symfony 2.2.
  • Loading branch information...
2 parents 6672ebc + 59c5013 commit 453181659c5fdbb37e3834f1c6f40c387acece29 @fabpot fabpot committed Sep 18, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 Normalizer/GetSetMethodNormalizer.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Serializer\Normalizer;
+use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Exception\RuntimeException;
@@ -42,12 +43,14 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer implements Normal
* Set normalization callbacks
* @param array $callbacks help normalize the result
+ *
+ * @throws InvalidArgumentException if a non-callable callback is set
public function setCallbacks(array $callbacks)
foreach ($callbacks as $attribute => $callback) {
if (!is_callable($callback)) {
- throw new \InvalidArgumentException(sprintf('The given callback for attribute "%s" is not callable.', $attribute));
+ throw new InvalidArgumentException(sprintf('The given callback for attribute "%s" is not callable.', $attribute));
$this->callbacks = $callbacks;

0 comments on commit 4531816

Please sign in to comment.