Skip to content

Commit

Permalink
minor #23322 [Serializer] Improve CircularReference detection message…
Browse files Browse the repository at this point in the history
… (ScullWM)

This PR was merged into the 2.7 branch.

Discussion
----------

[Serializer] Improve CircularReference detection message

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

Hi,
I've get a CircularReferenceException error while serializing object with nested levels. Detect a CircularReference is great, but having more information about the object that generate this exception is better.

I simply suggest to add a `get_class` of the current object in the error message.

Before:
`A circular reference has been detected (configured limit: 1).`

After (edit)
`A circular reference has been detected when serializing the object of class "App\Domain\User" (configured limit: 1).`

Commits
-------

3a529e3 Improve CircularReferenceException message
  • Loading branch information
fabpot committed Jul 3, 2017
2 parents 77d06b5 + 3a529e3 commit 71a69b4
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -228,7 +228,7 @@ protected function handleCircularReference($object)
return call_user_func($this->circularReferenceHandler, $object);
}

throw new CircularReferenceException(sprintf('A circular reference has been detected (configured limit: %d).', $this->circularReferenceLimit));
throw new CircularReferenceException(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d)', get_class($object), $this->circularReferenceLimit));
}

/**
Expand Down

0 comments on commit 71a69b4

Please sign in to comment.