mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-3289: Better exception description on some mapping errors #4069
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Aug 31, 2014).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user lmammino:
Mapping problems does not always throw very explicit exceptions.
I had this feeling with a very common error:
{quote}
This behaviour is (currently) not supported by Doctrine 2"
{quote}
I essentially forgot to add a "mapped-by" attribute in my mappings and, given this generic message, I admit I had to spend a bit of time before being able to spot the mistake.
That's the code that detected the problem and triggered the proper exception.
Within the
$mappingvariable I see we have a lot of useful information about the problem. Why don't use them to create a very helpful exception message that reports the exact mapped entity and field that raised the error?IMHO this will grant a better developer experience, especially for doctrine newcomers!
@doctrinebot commented on GitHub (Sep 1, 2014):
Comment created by @ocramius:
Hey [~lmammino], could you come up with an exception message that makes sense to you? This kind of improvement is trivial to implement, so it should be quick...
@doctrinebot commented on GitHub (Sep 1, 2014):
Comment created by lmammino:
Hi [~ocramius] :)
I think something like:
{quote}
One to Many relationships without "mapped-by" attribute are not allowed. (Found in "\Foo\Bar\SomeEntity", field "somefield")
{quote}
Will be good enough to give developers some clue about where the problem lies. Anyway I'm not sure it covers all the possible cases for this exception and that it is consistent with other error messages within the codebase.