fix: http message error

This commit is contained in:
Maël Gangloff
2024-08-07 16:29:37 +02:00
parent a0d2639311
commit cbd73aad4e

View File

@@ -116,6 +116,7 @@ readonly class RDAPService
* @throws HttpExceptionInterface * @throws HttpExceptionInterface
* @throws TransportExceptionInterface * @throws TransportExceptionInterface
* @throws DecodingExceptionInterface * @throws DecodingExceptionInterface
* @throws \Throwable
*/ */
public function registerDomains(array $domains): void public function registerDomains(array $domains): void
{ {
@@ -130,6 +131,7 @@ readonly class RDAPService
* @throws RedirectionExceptionInterface * @throws RedirectionExceptionInterface
* @throws DecodingExceptionInterface * @throws DecodingExceptionInterface
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
* @throws \Throwable
*/ */
public function registerDomain(string $fqdn): Domain public function registerDomain(string $fqdn): Domain
{ {
@@ -162,7 +164,7 @@ readonly class RDAPService
$res = $this->client->request( $res = $this->client->request(
'GET', $rdapServerUrl.'domain/'.$idnDomain 'GET', $rdapServerUrl.'domain/'.$idnDomain
)->toArray(); )->toArray();
} catch (ClientException $e) { } catch (\Throwable $e) {
if (null !== $domain) { if (null !== $domain) {
$this->logger->notice('The domain name {idnDomain} has been deleted from the WHOIS database.', [ $this->logger->notice('The domain name {idnDomain} has been deleted from the WHOIS database.', [
'idnDomain' => $idnDomain, 'idnDomain' => $idnDomain,
@@ -173,6 +175,11 @@ readonly class RDAPService
$this->em->persist($domain); $this->em->persist($domain);
$this->em->flush(); $this->em->flush();
} }
if ($e instanceof ClientException && 404 === $e->getResponse()->getStatusCode()) {
throw new NotFoundHttpException('The domain name is not present in the WHOIS database.');
}
throw $e; throw $e;
} }