Skip to content

Commit a49c6bc

Browse files
committed
reuse unsupported tld for getprice
1 parent d36455e commit a49c6bc

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/Domains/Registrar/Adapter/Mock.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Utopia\Domains\Registrar\Exception\DomainTakenException;
99
use Utopia\Domains\Registrar\Exception\InvalidContactException;
1010
use Utopia\Domains\Registrar\Exception\PriceNotFoundException;
11+
use Utopia\Domains\Registrar\Exception\UnsupportedTldException;
1112
use Utopia\Domains\Registrar\Domain;
1213
use Utopia\Domains\Registrar\Renewal;
1314
use Utopia\Domains\Registrar\TransferStatus;
@@ -287,7 +288,7 @@ public function getPrice(string $domain, int $periodYears = 1, string $regType =
287288
$tld = end($parts);
288289

289290
if (!in_array($tld, $this->supportedTlds)) {
290-
throw new PriceNotFoundException("TLD .{$tld} is not supported", self::RESPONSE_CODE_BAD_REQUEST);
291+
throw new UnsupportedTldException("TLD .{$tld} is not supported", self::RESPONSE_CODE_BAD_REQUEST);
291292
}
292293

293294
$basePrice = $this->defaultPrice;

src/Domains/Registrar/Adapter/NameCom.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,9 @@ public function getPrice(string $domain, int $periodYears = 1, string $regType =
393393
case $e instanceof PriceNotFoundException:
394394
throw $e;
395395

396+
case $this->matchError($e) === self::ERROR_UNSUPPORTED_TLD:
397+
throw new UnsupportedTldException($message, $code, $e);
398+
396399
case in_array($this->matchError($e), [self::ERROR_NOT_FOUND, self::ERROR_INVALID_DOMAIN]):
397400
throw new PriceNotFoundException($message, $code, $e);
398401

tests/Registrar/Base.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Utopia\Domains\Registrar\Exception\DomainNotTransferableException;
1010
use Utopia\Domains\Registrar\Exception\InvalidAuthCodeException;
1111
use Utopia\Domains\Registrar\Exception\InvalidContactException;
12-
use Utopia\Domains\Registrar\Exception\PriceNotFoundException;
12+
use Utopia\Domains\Registrar\Exception\UnsupportedTldException;
1313
use Utopia\Domains\Registrar\TransferStatusEnum;
1414
use Utopia\Domains\Registrar\UpdateDetails;
1515
use Utopia\Domains\Registrar\Price;
@@ -230,7 +230,7 @@ public function testGetPrice(): void
230230

231231
public function testGetPriceWithInvalidDomain(): void
232232
{
233-
$this->expectException(PriceNotFoundException::class);
233+
$this->expectException(UnsupportedTldException::class);
234234
$this->getRegistrar()->getPrice("invalid.invalidtld", 1, Registrar::REG_TYPE_NEW);
235235
}
236236

0 commit comments

Comments
 (0)