-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
improved error handling for invalid association values #2 #1248
Conversation
Possibly to do: 1. Make custom Exception for line 713 2. Make custom Exception for line 817 3. Does the object check on line 816 slow down the code too much? Alternatively a try-catch could be put around line 1415 or higher up.
Hello, thank you for creating this pull request. I have automatically opened an issue http://www.doctrine-project.org/jira/browse/DDC-3490 We use Jira to track the state of pull requests and the versions they got |
$this->computeAssociationChanges($assoc, $val); | ||
try { | ||
$this->computeAssociationChanges($assoc, $val); | ||
} catch (\Exception $ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't catch a generic exception here: be specific
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how i can track all the possible situations which yield all possible Exceptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flip111 writing these tests isn't that problematic if you keep the test asset as simple as possible.
@flip111 also, please provide tests for this enhancement |
`@return self` trend break with `@return ORMInvalidArgumentException`
Add unused parameters for `invalidAssociation`
@Ocramius i totally lost track (since 10 months) how i even arrived at this situation where this error would be useful. I hope not to forgot the PR this time though ^^ |
removed one `)` too many
rename duplicate method
rename duplicate method
@flip111 the original PR was probably trying to give a better meaning to stuff like: class Foo
{
/** @ManyToOne(targetEntity="Bar") */
public $bar;
}
$foo = new Foo;
$foo->bar = 'baz'; // wrong - exception
$foo->bar = []; // wrong - exception
$foo->bar = new ArrayCollection; // wrong - exception
$foo->bar = new stdClass; // wrong - exception
$foo->bar = new Bar; // correct |
remove added `value` to exception
I would strongly discourage you from writing code in github editor. Checkout the branch and fix it locally. It's more effective and IDE tells about problems github won't. |
Thank you @Ocramius i had already a hard time imagining being able to finish this PR |
@flip111 check the merge commit, the test was not that terrible after all :-) |
Ye i know it's not a big change. Just that Doctrine internal code is pretty hard to get into. I guess that goes for any ORMs though.. I checked the commit, you added two cases on the 2000+ lines, that's nice. I remember when i was testing i needed that catch around line 710 ... perhaps that has changed by now. |
@flip111 yeah, the association exception throwing was enough :-) |
Possibly to do:
Previous: #1016