mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 17:55:42 +00:00
feat: explcit HTTP errors
This commit is contained in:
parent
21298b07a2
commit
e393bcf0af
@ -5,6 +5,7 @@ namespace App\Config\Connector;
|
||||
use App\Entity\Domain;
|
||||
use Symfony\Component\HttpClient\HttpOptions;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
@ -89,7 +90,6 @@ readonly class GandiConnector implements ConnectorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
* @throws TransportExceptionInterface
|
||||
*/
|
||||
public static function verifyAuthData(array $authData, HttpClientInterface $client): array
|
||||
@ -106,7 +106,7 @@ readonly class GandiConnector implements ConnectorInterface
|
||||
|| true !== $ownerLegalAge
|
||||
|| true !== $waiveRetractationPeriod
|
||||
) {
|
||||
throw new \Exception('Bad authData schema');
|
||||
throw new BadRequestHttpException('Bad authData schema');
|
||||
}
|
||||
|
||||
$response = $client->request('GET', '/v5/organization/user-info', (new HttpOptions())
|
||||
@ -117,7 +117,7 @@ readonly class GandiConnector implements ConnectorInterface
|
||||
);
|
||||
|
||||
if (Response::HTTP_OK !== $response->getStatusCode()) {
|
||||
throw new \Exception('The status of these credentials is not valid');
|
||||
throw new BadRequestHttpException('The status of these credentials is not valid');
|
||||
}
|
||||
|
||||
$authDataReturned = [
|
||||
|
||||
@ -12,6 +12,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;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
@ -75,7 +76,7 @@ class ConnectorController extends AbstractController
|
||||
} elseif (ConnectorProvider::GANDI === $provider) {
|
||||
$authData = GandiConnector::verifyAuthData($connector->getAuthData(), $client);
|
||||
} else {
|
||||
throw new \Exception('Unknown provider');
|
||||
throw new BadRequestHttpException('Unknown provider');
|
||||
}
|
||||
|
||||
$connector->setAuthData($authData);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user