mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: forward the error message to the client if an error occurs on the RDAP server side
This commit is contained in:
@@ -42,6 +42,7 @@ api_platform:
|
||||
App\Exception\TldNotSupportedException: 400
|
||||
App\Exception\UnknownRdapServerException: 400
|
||||
App\Exception\UnsupportedDsnScheme: 400
|
||||
App\Exception\RdapServerException: 400
|
||||
|
||||
# Provider exception
|
||||
App\Exception\Provider\UserNoExplicitConsentException: 451
|
||||
|
||||
13
src/Exception/RdapServerException.php
Normal file
13
src/Exception/RdapServerException.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exception;
|
||||
|
||||
use Symfony\Component\HttpClient\Exception\ServerException;
|
||||
|
||||
class RdapServerException extends \Exception
|
||||
{
|
||||
public static function fromServerException(ServerException $e): self
|
||||
{
|
||||
return new self($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ use App\Entity\RdapServer;
|
||||
use App\Entity\Tld;
|
||||
use App\Exception\DomainNotFoundException;
|
||||
use App\Exception\MalformedDomainException;
|
||||
use App\Exception\RdapServerException;
|
||||
use App\Exception\TldNotSupportedException;
|
||||
use App\Exception\UnknownRdapServerException;
|
||||
use App\Repository\DomainEntityRepository;
|
||||
@@ -37,6 +38,7 @@ use Doctrine\ORM\OptimisticLockException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
use Symfony\Component\HttpClient\Exception\ClientException;
|
||||
use Symfony\Component\HttpClient\Exception\ServerException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||
@@ -249,7 +251,7 @@ class RDAPService
|
||||
]);
|
||||
|
||||
try {
|
||||
$req = $this->client->request('GET', $rdapServerUrl.'domain/'.$idnDomain);
|
||||
$req = $this->client->request('GET', 'http://localhost:3000');
|
||||
$this->statService->incrementStat('stats.rdap_queries.count');
|
||||
|
||||
return $req->toArray();
|
||||
@@ -292,13 +294,17 @@ class RDAPService
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
throw DomainNotFoundException::fromDomain($idnDomain);
|
||||
return DomainNotFoundException::fromDomain($idnDomain);
|
||||
}
|
||||
|
||||
$this->logger->error('Unable to perform an RDAP query for this domain name', [
|
||||
'ldhName' => $idnDomain,
|
||||
]);
|
||||
|
||||
if ($e instanceof ServerException) {
|
||||
return RdapServerException::fromServerException($e);
|
||||
}
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user