Skip to content
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

Add missing ids in exception message #1515

Merged
merged 2 commits into from May 6, 2019

Conversation

deguif
Copy link
Contributor

@deguif deguif commented May 6, 2019

Display ids of missing objects in exception message when ignore_missing option is used.

@deguif
Copy link
Contributor Author

deguif commented May 6, 2019

I added this information, as currently the exception display the list of all the ids, but to get the missing id(s), it requires to check manually which id(s) is/are missing.
This is easier to spot the missing id(s) and do something with them.

@XWB
Copy link
Member

XWB commented May 6, 2019

You will have to change the unit test as well:

  1. FOS\ElasticaBundle\Tests\Unit\Doctrine\AbstractElasticaToModelTransformerTest::testAnExceptionIsThrownWhenTheNumberOfFoundObjectsIsLessThanTheNumberOfResults with data set #0 (array(Elastica\Result Object (...), Elastica\Result Object (...), Elastica\Result Object (...)), array(FOS\ElasticaBundle\Tests\Unit\Doctrine\Foo Object (...), FOS\ElasticaBundle\Tests\Unit\Doctrine\Foo Object (...), FOS\ElasticaBundle\Tests\Unit\Doctrine\Foo Object (...)))
    Failed asserting that exception message 'Cannot find corresponding Doctrine objects (0) for all Elastica results (3). Missing IDs: 1, 2, 3. IDs: 1, 2, 3' contains 'Cannot find corresponding Doctrine objects (0) for all Elastica results (3). IDs: 1, 2, 3'.

return $propertyAccessor->getValue($object, $identifier);
}, $objects));

throw new \RuntimeException(sprintf('Cannot find corresponding Doctrine objects (%d) for all Elastica results (%d). Missing IDs: %s. IDs: %s', $objectsCnt, $elasticaObjectsCnt, implode(', ', $missingIds), implode(', ', $ids)));
Copy link
Contributor Author

@deguif deguif May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should find a better wording for the exception message, but I'm not the best for this kind of things.

@XWB
Copy link
Member

XWB commented May 6, 2019

It's fine for now :)

@XWB XWB merged commit b08530d into FriendsOfSymfony:master May 6, 2019
@deguif deguif deleted the missing-ids-in-exception branch May 6, 2019 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants