Skip to content

Commit

Permalink
refactor #11492 Making error messages in example factories more descr…
Browse files Browse the repository at this point in the history
…iptive (mamazu)

This PR was merged into the 1.7 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | -
| License         | MIT

When loading of a fixture fails because the factory can not find the objects it should attach to  precise error messages are very helpful.

Before:
![image](https://user-images.githubusercontent.com/14860264/82560206-46d20480-9b71-11ea-9dbe-819c64daeace.png)

After:
![image](https://user-images.githubusercontent.com/14860264/82560104-0e322b00-9b71-11ea-91d4-3c37fb7e7ed7.png)



Commits
-------

3a23f93 Making error messages in example factories more descriptive
  • Loading branch information
lchrusciel committed May 22, 2020
2 parents ee5254c + 3a23f93 commit a01e2ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function create(array $options = []): AddressInterface
private function assertCountryCodeIsValid(string $code): void
{
$country = $this->countryRepository->findOneBy(['code' => $code]);
Assert::notNull($country);
Assert::notNull($country, sprintf('Trying to create address with invalid country code: "%s"', $code));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private function configureProductAttributeValue(string $code, string $localeCode
/** @var ProductAttributeInterface|null $productAttribute */
$productAttribute = $this->productAttributeRepository->findOneBy(['code' => $code]);

Assert::notNull($productAttribute);
Assert::notNull($productAttribute, sprintf('Can not find product attribute with code: "%s"', $code));

/** @var ProductAttributeValueInterface $productAttributeValue */
$productAttributeValue = $this->productAttributeValueFactory->createNew();
Expand Down

0 comments on commit a01e2ba

Please sign in to comment.