From 7f30d446fa68d38d901d04247fa296297893110e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Tue, 6 Aug 2024 17:29:29 +0200 Subject: [PATCH 1/8] fix: show error message if Retry-After header is present in response --- assets/components/RegisterForm.tsx | 7 ++++++ assets/pages/search/DomainSearchPage.tsx | 10 ++++++-- translations/translations.pot | 30 ++++++++++++++---------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/assets/components/RegisterForm.tsx b/assets/components/RegisterForm.tsx index 9f15f1a..b19391e 100644 --- a/assets/components/RegisterForm.tsx +++ b/assets/components/RegisterForm.tsx @@ -19,6 +19,13 @@ export function RegisterForm() { register(data.username, data.password).then(() => { navigate('/home') }).catch((e) => { + + if (e.response?.status === 429) { + const duration = e.response.headers['retry-after'] + setError(t`Please retry after ${duration} seconds`) + return; + } + if (e.response.data.message !== undefined) { setError(e.response.data.message) } else { diff --git a/assets/pages/search/DomainSearchPage.tsx b/assets/pages/search/DomainSearchPage.tsx index 451af9d..60723bc 100644 --- a/assets/pages/search/DomainSearchPage.tsx +++ b/assets/pages/search/DomainSearchPage.tsx @@ -19,9 +19,15 @@ export default function DomainSearchPage() { setDomain(d) messageApi.success(t`Found !`) }).catch((e: AxiosError) => { - const data = e?.response?.data as { detail: string } setDomain(undefined) - messageApi.error(data.detail ?? t`An error occurred`) + + if (e.response?.status === 429) { + const duration = e.response.headers['retry-after'] + messageApi.error(t`Please retry after ${duration} seconds`) + return; + } + const data = e?.response?.data as { detail: string } + messageApi.error(data.detail !== '' ? data.detail : t`An error occurred`) }) } diff --git a/translations/translations.pot b/translations/translations.pot index 7e2a879..2f31612 100644 --- a/translations/translations.pot +++ b/translations/translations.pot @@ -4,19 +4,19 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n!=1);\n" #: assets/components/LoginForm.tsx:47 -#: assets/components/RegisterForm.tsx:33 +#: assets/components/RegisterForm.tsx:40 msgid "Error" msgstr "" #: assets/components/LoginForm.tsx:62 -#: assets/components/RegisterForm.tsx:48 +#: assets/components/RegisterForm.tsx:55 msgid "Email address" msgstr "" #: assets/components/LoginForm.tsx:64 #: assets/components/LoginForm.tsx:72 -#: assets/components/RegisterForm.tsx:50 -#: assets/components/RegisterForm.tsx:58 +#: assets/components/RegisterForm.tsx:57 +#: assets/components/RegisterForm.tsx:65 #: assets/components/search/DomainSearchBar.tsx:23 #: assets/components/tracking/ConnectorForm.tsx:40 #: assets/components/tracking/ConnectorForm.tsx:66 @@ -31,7 +31,7 @@ msgid "Required" msgstr "" #: assets/components/LoginForm.tsx:70 -#: assets/components/RegisterForm.tsx:56 +#: assets/components/RegisterForm.tsx:63 msgid "Password" msgstr "" @@ -356,7 +356,13 @@ msgstr "" msgid "Log in" msgstr "" -#: assets/components/RegisterForm.tsx:65 +#: assets/components/RegisterForm.tsx:25 +#: assets/pages/search/DomainSearchPage.tsx:26 +#, javascript-format +msgid "Please retry after ${ duration } seconds" +msgstr "" + +#: assets/components/RegisterForm.tsx:72 #: assets/pages/LoginPage.tsx:30 msgid "Register" msgstr "" @@ -365,7 +371,7 @@ msgstr "" msgid "Found !" msgstr "" -#: assets/pages/search/DomainSearchPage.tsx:24 +#: assets/pages/search/DomainSearchPage.tsx:30 #: assets/pages/tracking/ConnectorsPage.tsx:21 #: assets/pages/tracking/ConnectorsPage.tsx:29 #: assets/pages/tracking/WatchlistPage.tsx:49 @@ -374,23 +380,23 @@ msgstr "" msgid "An error occurred" msgstr "" -#: assets/pages/search/DomainSearchPage.tsx:29 +#: assets/pages/search/DomainSearchPage.tsx:35 msgid "Domain finder" msgstr "" -#: assets/pages/search/DomainSearchPage.tsx:50 +#: assets/pages/search/DomainSearchPage.tsx:56 msgid "EPP Status Codes" msgstr "" -#: assets/pages/search/DomainSearchPage.tsx:60 +#: assets/pages/search/DomainSearchPage.tsx:66 msgid "Timeline" msgstr "" -#: assets/pages/search/DomainSearchPage.tsx:65 +#: assets/pages/search/DomainSearchPage.tsx:71 msgid "Entities" msgstr "" -#: assets/pages/search/DomainSearchPage.tsx:73 +#: assets/pages/search/DomainSearchPage.tsx:79 msgid "" "Although the domain exists in my database, it has been deleted from the " "WHOIS by its registrar." From c9dc6e58ea29f13dae4040bd73a2175d69e39d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Tue, 6 Aug 2024 17:34:45 +0200 Subject: [PATCH 2/8] fix: show TextPage even if user is not logged in --- assets/App.tsx | 3 ++- translations/translations.pot | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/assets/App.tsx b/assets/App.tsx index cead534..2bd4a37 100644 --- a/assets/App.tsx +++ b/assets/App.tsx @@ -48,7 +48,8 @@ export default function App() { if (location.pathname === '/login') navigate('/home') }).catch(() => { setIsAuthenticated(false) - if (location.pathname !== '/login') navigate('/home') + const pathname = location.pathname + if (!['/login', '/tos', '/faq', '/privacy'].includes(pathname)) navigate('/home') }) }, []); diff --git a/translations/translations.pot b/translations/translations.pot index 2f31612..00ad76a 100644 --- a/translations/translations.pot +++ b/translations/translations.pot @@ -539,23 +539,23 @@ msgid "" "another" msgstr "" -#: assets/App.tsx:100 +#: assets/App.tsx:101 msgid "TOS" msgstr "" -#: assets/App.tsx:101 +#: assets/App.tsx:102 msgid "Privacy Policy" msgstr "" -#: assets/App.tsx:102 +#: assets/App.tsx:103 msgid "FAQ" msgstr "" -#: assets/App.tsx:104 +#: assets/App.tsx:105 msgid "Documentation" msgstr "" -#: assets/App.tsx:107 +#: assets/App.tsx:108 #, javascript-format msgid "" "${ ProjectLink } is an open source project distributed under the ${ " From dfe4454fb2d7e8f4027d917b4569910dac8aa67d Mon Sep 17 00:00:00 2001 From: Weblate Date: Tue, 6 Aug 2024 15:35:17 +0000 Subject: [PATCH 3/8] Update translation files Updated by "Update PO files to match POT (msgmerge)" add-on in Weblate. --- translations/fr.po | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/translations/fr.po b/translations/fr.po index 59301f3..7998771 100644 --- a/translations/fr.po +++ b/translations/fr.po @@ -11,16 +11,16 @@ msgstr "" "Plural-Forms: nplurals=2; plural=n > 1;\n" "X-Generator: Weblate 5.6\n" -#: assets/components/LoginForm.tsx:47 assets/components/RegisterForm.tsx:33 +#: assets/components/LoginForm.tsx:47 assets/components/RegisterForm.tsx:40 msgid "Error" msgstr "Erreur" -#: assets/components/LoginForm.tsx:62 assets/components/RegisterForm.tsx:48 +#: assets/components/LoginForm.tsx:62 assets/components/RegisterForm.tsx:55 msgid "Email address" msgstr "Adresse e-mail" #: assets/components/LoginForm.tsx:64 assets/components/LoginForm.tsx:72 -#: assets/components/RegisterForm.tsx:50 assets/components/RegisterForm.tsx:58 +#: assets/components/RegisterForm.tsx:57 assets/components/RegisterForm.tsx:65 #: assets/components/search/DomainSearchBar.tsx:23 #: assets/components/tracking/ConnectorForm.tsx:40 #: assets/components/tracking/ConnectorForm.tsx:66 @@ -34,7 +34,7 @@ msgstr "Adresse e-mail" msgid "Required" msgstr "Requis" -#: assets/components/LoginForm.tsx:70 assets/components/RegisterForm.tsx:56 +#: assets/components/LoginForm.tsx:70 assets/components/RegisterForm.tsx:63 msgid "Password" msgstr "Mot de passe" @@ -366,7 +366,13 @@ msgstr "Se déconnecter" msgid "Log in" msgstr "Se connecter" -#: assets/components/RegisterForm.tsx:65 assets/pages/LoginPage.tsx:30 +#: assets/components/RegisterForm.tsx:25 +#: assets/pages/search/DomainSearchPage.tsx:26 +#, javascript-format +msgid "Please retry after ${ duration } seconds" +msgstr "" + +#: assets/components/RegisterForm.tsx:72 assets/pages/LoginPage.tsx:30 msgid "Register" msgstr "S'enregistrer" @@ -374,7 +380,7 @@ msgstr "S'enregistrer" msgid "Found !" msgstr "Trouvé !" -#: assets/pages/search/DomainSearchPage.tsx:24 +#: assets/pages/search/DomainSearchPage.tsx:30 #: assets/pages/tracking/ConnectorsPage.tsx:21 #: assets/pages/tracking/ConnectorsPage.tsx:29 #: assets/pages/tracking/WatchlistPage.tsx:49 @@ -383,23 +389,23 @@ msgstr "Trouvé !" msgid "An error occurred" msgstr "Une erreur s'est produite" -#: assets/pages/search/DomainSearchPage.tsx:29 +#: assets/pages/search/DomainSearchPage.tsx:35 msgid "Domain finder" msgstr "Rechercher un domaine" -#: assets/pages/search/DomainSearchPage.tsx:50 +#: assets/pages/search/DomainSearchPage.tsx:56 msgid "EPP Status Codes" msgstr "Codes de statut EPP" -#: assets/pages/search/DomainSearchPage.tsx:60 +#: assets/pages/search/DomainSearchPage.tsx:66 msgid "Timeline" msgstr "Chronologie" -#: assets/pages/search/DomainSearchPage.tsx:65 +#: assets/pages/search/DomainSearchPage.tsx:71 msgid "Entities" msgstr "Entités" -#: assets/pages/search/DomainSearchPage.tsx:73 +#: assets/pages/search/DomainSearchPage.tsx:79 msgid "" "Although the domain exists in my database, it has been deleted from the " "WHOIS by its registrar." @@ -566,23 +572,23 @@ msgstr "" "Le domaine est libre mais est un premium. Son prix est variable d'un domaine " "à l'autre" -#: assets/App.tsx:100 +#: assets/App.tsx:101 msgid "TOS" msgstr "CGU" -#: assets/App.tsx:101 +#: assets/App.tsx:102 msgid "Privacy Policy" msgstr "Politique de confidentialité" -#: assets/App.tsx:102 +#: assets/App.tsx:103 msgid "FAQ" msgstr "FAQ" -#: assets/App.tsx:104 +#: assets/App.tsx:105 msgid "Documentation" msgstr "Documentation" -#: assets/App.tsx:107 +#: assets/App.tsx:108 #, javascript-format msgid "" "${ ProjectLink } is an open source project distributed under the " From 5a8b08c201cc0de0e7a68ad4eed7d72706aa22a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Tue, 6 Aug 2024 15:35:58 +0000 Subject: [PATCH 4/8] Translated using Weblate (French) Currently translated at 100.0% (122 of 122 strings) --- translations/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translations/fr.po b/translations/fr.po index 7998771..d09a5b7 100644 --- a/translations/fr.po +++ b/translations/fr.po @@ -1,6 +1,6 @@ msgid "" msgstr "" -"PO-Revision-Date: 2024-08-05 01:44+0000\n" +"PO-Revision-Date: 2024-08-06 15:36+0000\n" "Last-Translator: Maël Gangloff \n" "Language-Team: French \n" @@ -370,7 +370,7 @@ msgstr "Se connecter" #: assets/pages/search/DomainSearchPage.tsx:26 #, javascript-format msgid "Please retry after ${ duration } seconds" -msgstr "" +msgstr "Merci de réessayer dans ${ durée } secondes" #: assets/components/RegisterForm.tsx:72 assets/pages/LoginPage.tsx:30 msgid "Register" From ba796c9995d78f3d6a6fd55987beb47de736685e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Tue, 6 Aug 2024 15:41:43 +0000 Subject: [PATCH 5/8] Translated using Weblate (French) Currently translated at 100.0% (122 of 122 strings) --- translations/fr.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translations/fr.po b/translations/fr.po index d09a5b7..88fbe05 100644 --- a/translations/fr.po +++ b/translations/fr.po @@ -1,6 +1,6 @@ msgid "" msgstr "" -"PO-Revision-Date: 2024-08-06 15:36+0000\n" +"PO-Revision-Date: 2024-08-06 15:41+0000\n" "Last-Translator: Maël Gangloff \n" "Language-Team: French \n" @@ -370,7 +370,7 @@ msgstr "Se connecter" #: assets/pages/search/DomainSearchPage.tsx:26 #, javascript-format msgid "Please retry after ${ duration } seconds" -msgstr "Merci de réessayer dans ${ durée } secondes" +msgstr "Merci de réessayer dans ${ duration } secondes" #: assets/components/RegisterForm.tsx:72 assets/pages/LoginPage.tsx:30 msgid "Register" From 1fd5dd90dbf3e6f551552fa3cd0462a818b981e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Tue, 6 Aug 2024 17:52:26 +0200 Subject: [PATCH 6/8] feat: Not Found error if the domain is not in the WHOIS database --- src/Controller/DomainRefreshController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Controller/DomainRefreshController.php b/src/Controller/DomainRefreshController.php index b24344a..2e11957 100644 --- a/src/Controller/DomainRefreshController.php +++ b/src/Controller/DomainRefreshController.php @@ -10,6 +10,7 @@ use App\Service\RDAPService; use Psr\Log\LoggerInterface; use Random\Randomizer; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Messenger\Exception\ExceptionInterface; @@ -72,7 +73,11 @@ class DomainRefreshController extends AbstractController } $updatedAt = null === $domain ? new \DateTimeImmutable('now') : $domain->getUpdatedAt(); - $domain = $this->RDAPService->registerDomain($idnDomain); + try { + $domain = $this->RDAPService->registerDomain($idnDomain); + } catch (HttpExceptionInterface) { + throw new NotFoundHttpException('This domain name cannot be found in the WHOIS database'); + } $randomizer = new Randomizer(); $watchLists = $randomizer->shuffleArray($domain->getWatchLists()->toArray()); From e46851ca54b98958a88c528259c51fa544162579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Tue, 6 Aug 2024 19:05:02 +0200 Subject: [PATCH 7/8] feat: add updatedAt on DomainEntity --- migrations/Version20240806170123.php | 34 ++++++++++++++++++++++ src/Controller/DomainRefreshController.php | 1 - src/Entity/DomainEntity.php | 28 ++++++++++++++++++ src/Service/RDAPService.php | 3 +- 4 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 migrations/Version20240806170123.php diff --git a/migrations/Version20240806170123.php b/migrations/Version20240806170123.php new file mode 100644 index 0000000..1b56581 --- /dev/null +++ b/migrations/Version20240806170123.php @@ -0,0 +1,34 @@ +addSql('ALTER TABLE domain_entity ADD updated_at DATE DEFAULT CURRENT_TIMESTAMP NOT NULL'); + $this->addSql('COMMENT ON COLUMN domain_entity.updated_at IS \'(DC2Type:date_immutable)\''); + $this->addSql('ALTER TABLE domain_entity ALTER updated_at DROP DEFAULT'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE domain_entity DROP updated_at'); + } +} diff --git a/src/Controller/DomainRefreshController.php b/src/Controller/DomainRefreshController.php index 2e11957..f4d81df 100644 --- a/src/Controller/DomainRefreshController.php +++ b/src/Controller/DomainRefreshController.php @@ -32,7 +32,6 @@ class DomainRefreshController extends AbstractController /** * @throws TransportExceptionInterface - * @throws HttpExceptionInterface * @throws DecodingExceptionInterface * @throws ExceptionInterface * @throws \Exception diff --git a/src/Entity/DomainEntity.php b/src/Entity/DomainEntity.php index 50ad16d..54a8f00 100644 --- a/src/Entity/DomainEntity.php +++ b/src/Entity/DomainEntity.php @@ -27,6 +27,15 @@ class DomainEntity #[Groups(['domain-entity:entity', 'domain-entity:domain'])] private array $roles = []; + #[ORM\Column(type: Types::DATE_IMMUTABLE)] + #[Groups(['domain-entity:entity', 'domain-entity:domain'])] + private ?\DateTimeImmutable $updatedAt = null; + + public function __construct() + { + $this->updatedAt = new \DateTimeImmutable('now'); + } + public function getDomain(): ?Domain { return $this->domain; @@ -65,4 +74,23 @@ class DomainEntity return $this; } + + public function getUpdatedAt(): ?\DateTimeImmutable + { + return $this->updatedAt; + } + + public function setUpdatedAt(\DateTimeImmutable $updatedAt): static + { + $this->updatedAt = $updatedAt; + + return $this; + } + + #[ORM\PrePersist] + #[ORM\PreUpdate] + public function updateTimestamps(): void + { + $this->setUpdatedAt(new \DateTimeImmutable('now')); + } } diff --git a/src/Service/RDAPService.php b/src/Service/RDAPService.php index 92e7d5e..8f4bc9b 100644 --- a/src/Service/RDAPService.php +++ b/src/Service/RDAPService.php @@ -258,7 +258,8 @@ readonly class RDAPService $domain->addDomainEntity($domainEntity ->setDomain($domain) ->setEntity($entity) - ->setRoles($roles)); + ->setRoles($roles)) + ->updateTimestamps(); $this->em->persist($domainEntity); $this->em->flush(); From 342b3ff9873b460c7f6ccb1973d3b642bd3003b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Tue, 6 Aug 2024 21:43:37 +0200 Subject: [PATCH 8/8] feat: explcit HTTP errors --- src/Config/Connector/OvhConnector.php | 5 +++-- src/Controller/ConnectorController.php | 3 ++- src/Controller/DomainRefreshController.php | 8 ++------ src/Service/RDAPService.php | 11 +++++------ 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/Config/Connector/OvhConnector.php b/src/Config/Connector/OvhConnector.php index 41e1862..fca2b14 100644 --- a/src/Config/Connector/OvhConnector.php +++ b/src/Config/Connector/OvhConnector.php @@ -4,6 +4,7 @@ namespace App\Config\Connector; use App\Entity\Domain; use Ovh\Api; +use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; readonly class OvhConnector implements ConnectorInterface { @@ -141,7 +142,7 @@ readonly class OvhConnector implements ConnectorInterface || true !== $ownerLegalAge || true !== $waiveRetractationPeriod ) { - throw new \Exception('Bad authData schema'); + throw new BadRequestHttpException('Bad authData schema'); } $conn = new Api( @@ -174,7 +175,7 @@ readonly class OvhConnector implements ConnectorInterface } if (!$ok) { - throw new \Exception('The credentials provided do not have enough permissions to purchase a domain name.'); + throw new BadRequestHttpException('The credentials provided do not have enough permissions to purchase a domain name.'); } } diff --git a/src/Controller/ConnectorController.php b/src/Controller/ConnectorController.php index 4209900..891fd90 100644 --- a/src/Controller/ConnectorController.php +++ b/src/Controller/ConnectorController.php @@ -11,6 +11,7 @@ use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; @@ -74,7 +75,7 @@ class ConnectorController extends AbstractController 'username' => $user->getUserIdentifier(), ]); } else { - throw new \Exception('Unknown provider'); + throw new BadRequestHttpException('Unknown provider'); } $this->logger->info('The new API connector requested by {username} has been successfully registered.', [ diff --git a/src/Controller/DomainRefreshController.php b/src/Controller/DomainRefreshController.php index f4d81df..e45bc36 100644 --- a/src/Controller/DomainRefreshController.php +++ b/src/Controller/DomainRefreshController.php @@ -10,7 +10,6 @@ use App\Service\RDAPService; use Psr\Log\LoggerInterface; use Random\Randomizer; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Messenger\Exception\ExceptionInterface; @@ -35,6 +34,7 @@ class DomainRefreshController extends AbstractController * @throws DecodingExceptionInterface * @throws ExceptionInterface * @throws \Exception + * @throws HttpExceptionInterface */ public function __invoke(string $ldhName, KernelInterface $kernel): ?Domain { @@ -72,11 +72,7 @@ class DomainRefreshController extends AbstractController } $updatedAt = null === $domain ? new \DateTimeImmutable('now') : $domain->getUpdatedAt(); - try { - $domain = $this->RDAPService->registerDomain($idnDomain); - } catch (HttpExceptionInterface) { - throw new NotFoundHttpException('This domain name cannot be found in the WHOIS database'); - } + $domain = $this->RDAPService->registerDomain($idnDomain); $randomizer = new Randomizer(); $watchLists = $randomizer->shuffleArray($domain->getWatchLists()->toArray()); diff --git a/src/Service/RDAPService.php b/src/Service/RDAPService.php index 8f4bc9b..4de1203 100644 --- a/src/Service/RDAPService.php +++ b/src/Service/RDAPService.php @@ -25,6 +25,8 @@ use App\Repository\TldRepository; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Exception\ORMException; use Psr\Log\LoggerInterface; +use Symfony\Component\HttpFoundation\Exception\BadRequestException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface; @@ -122,10 +124,10 @@ readonly class RDAPService } /** - * @throws \Exception * @throws TransportExceptionInterface * @throws DecodingExceptionInterface * @throws HttpExceptionInterface + * @throws \Exception */ public function registerDomain(string $fqdn): Domain { @@ -141,7 +143,7 @@ readonly class RDAPService $rdapServer = $this->rdapServerRepository->findOneBy(['tld' => $tld], ['updatedAt' => 'DESC']); if (null === $rdapServer) { - throw new \Exception('Unable to determine which RDAP server to contact'); + throw new NotFoundHttpException('Unable to determine which RDAP server to contact'); } /** @var ?Domain $domain */ @@ -331,14 +333,11 @@ readonly class RDAPService return $domain; } - /** - * @throws \Exception - */ private function getTld($domain): ?object { $lastDotPosition = strrpos($domain, '.'); if (false === $lastDotPosition) { - throw new \Exception('Domain must contain at least one dot'); + throw new BadRequestException('Domain must contain at least one dot'); } $tld = strtolower(substr($domain, $lastDotPosition + 1));