Skip to content

Commit

Permalink
MAGE-838 Localize exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
cammonro committed Jun 24, 2024
1 parent dcaa0c3 commit d7bb010
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Exception/ReplicaLimitExceededException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Algolia\AlgoliaSearch\Exception;

use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;
use Magento\Framework\Exception\LocalizedException;

class ReplicaLimitExceededException extends AlgoliaException
class ReplicaLimitExceededException extends LocalizedException
{
protected int $replicaCount = 0;

Expand Down
2 changes: 0 additions & 2 deletions Exception/TooManyCustomerGroupsAsReplicasException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Algolia\AlgoliaSearch\Exception;

use Algolia\AlgoliaSearch\Exception\ReplicaLimitExceededException;

class TooManyCustomerGroupsAsReplicasException extends ReplicaLimitExceededException
{
protected int $priceSortReplicaCount = 0;
Expand Down
5 changes: 3 additions & 2 deletions Model/Product/ReplicaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,15 @@ protected function isReplicaConfigurationValid(string $primaryIndexName, int $st
$sortingIndices = $this->configHelper->getSortingIndices($primaryIndexName, $storeId);
$validator = $this->validatorFactory->create();
if (!$validator->isReplicaConfigurationValid($sortingIndices)) {
$postfix = "Please note that there can be no more than " . $this->getMaxVirtualReplicasPerIndex() . " virtual replicas per index. Reverting to previous configuration.";
// TODO: Implement revert settings via ReplicaState
if ($validator->isTooManyCustomerGroups()) {
throw (new TooManyCustomerGroupsAsReplicasException("You have too many customer groups to enable virtual replicas on the pricing sort."))
throw (new TooManyCustomerGroupsAsReplicasException(__("You have too many customer groups to enable virtual replicas on the pricing sort. $postfix")))
->withReplicaCount($validator->getReplicaCount())
->withPriceSortReplicaCount($validator->getPriceSortReplicaCount());
}
else {
throw (new ReplicaLimitExceededException("Replica limit exceeded."))
throw (new ReplicaLimitExceededException(__("Replica limit exceeded. $postfix")))
->withReplicaCount($validator->getReplicaCount());
}
}
Expand Down

0 comments on commit d7bb010

Please sign in to comment.