-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catch TypeError during annotation instantiation and throw a more meaningful AnnotationException #437
Comments
If that's the matter of a simple try/catch/throw-decorated then I'd say got for it 👍 |
That's exactly what it is 😄 I think it's the two lines I mentioned, plus another two a bit lower in the code |
Plus tests 👀 |
I've created a draft ➡️ #438 It feels a bit tricky and bloated to catch exceptions and I could also collect the constructor argument types with the already collected data of the constructor arguments here: annotations/lib/Doctrine/Common/Annotations/DocParser.php Lines 614 to 619 in d13947c
However comparing types which are more complex is not something I want to do (union types, intersection types, interfaces, etc.). Update: @stof gave some input on the draft and I think not |
That'd be way simpler and effective, was going to propose same approach seeing all those regexps 👍 |
I pushed my new code in #438 . On the reported code, I now get this error:
It now clearly states that this happened on the |
I ran into this error:
I traced calls and variables back to a
@OneToMany
annotation on a property of an entity containing a misconfiguration and fixed it:It's not clear from the error neither the trace (coming from a query being executed and objects being hydrated) on which entity and which property this occurred.
I looked into
\Doctrine\Common\Annotations\DocParser
and there are many checks being done and many places where there might be a\Doctrine\Common\Annotations\AnnotationException
being thrown with clear messages.Should we catch
TypeError
s upon the annotation instantiation here and here and throw anAnnotationException
with a proper message containing the annotation and property on which it occurred?The text was updated successfully, but these errors were encountered: