Skip to content

Commit d7bb010

Browse files
committed
MAGE-838 Localize exceptions
1 parent dcaa0c3 commit d7bb010

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

Exception/ReplicaLimitExceededException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Algolia\AlgoliaSearch\Exception;
44

5-
use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;
5+
use Magento\Framework\Exception\LocalizedException;
66

7-
class ReplicaLimitExceededException extends AlgoliaException
7+
class ReplicaLimitExceededException extends LocalizedException
88
{
99
protected int $replicaCount = 0;
1010

Exception/TooManyCustomerGroupsAsReplicasException.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Algolia\AlgoliaSearch\Exception;
44

5-
use Algolia\AlgoliaSearch\Exception\ReplicaLimitExceededException;
6-
75
class TooManyCustomerGroupsAsReplicasException extends ReplicaLimitExceededException
86
{
97
protected int $priceSortReplicaCount = 0;

Model/Product/ReplicaManager.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,15 @@ protected function isReplicaConfigurationValid(string $primaryIndexName, int $st
275275
$sortingIndices = $this->configHelper->getSortingIndices($primaryIndexName, $storeId);
276276
$validator = $this->validatorFactory->create();
277277
if (!$validator->isReplicaConfigurationValid($sortingIndices)) {
278+
$postfix = "Please note that there can be no more than " . $this->getMaxVirtualReplicasPerIndex() . " virtual replicas per index. Reverting to previous configuration.";
278279
// TODO: Implement revert settings via ReplicaState
279280
if ($validator->isTooManyCustomerGroups()) {
280-
throw (new TooManyCustomerGroupsAsReplicasException("You have too many customer groups to enable virtual replicas on the pricing sort."))
281+
throw (new TooManyCustomerGroupsAsReplicasException(__("You have too many customer groups to enable virtual replicas on the pricing sort. $postfix")))
281282
->withReplicaCount($validator->getReplicaCount())
282283
->withPriceSortReplicaCount($validator->getPriceSortReplicaCount());
283284
}
284285
else {
285-
throw (new ReplicaLimitExceededException("Replica limit exceeded."))
286+
throw (new ReplicaLimitExceededException(__("Replica limit exceeded. $postfix")))
286287
->withReplicaCount($validator->getReplicaCount());
287288
}
288289
}

0 commit comments

Comments
 (0)