mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
chore: Exception type
This commit is contained in:
@@ -29,12 +29,12 @@ class GandiProvider extends AbstractProvider
|
||||
public function orderDomain(Domain $domain, bool $dryRun = false): void
|
||||
{
|
||||
if (!$domain->getDeleted()) {
|
||||
throw new \Exception('The domain name still appears in the WHOIS database');
|
||||
throw new \InvalidArgumentException('The domain name still appears in the WHOIS database');
|
||||
}
|
||||
|
||||
$ldhName = $domain->getLdhName();
|
||||
if (!$ldhName) {
|
||||
throw new \Exception('Domain name cannot be null');
|
||||
throw new \InvalidArgumentException('Domain name cannot be null');
|
||||
}
|
||||
|
||||
$authData = self::verifyAuthData($this->authData, $this->client);
|
||||
|
||||
@@ -49,12 +49,12 @@ class OvhProvider extends AbstractProvider
|
||||
public function orderDomain(Domain $domain, bool $dryRun = false): void
|
||||
{
|
||||
if (!$domain->getDeleted()) {
|
||||
throw new \Exception('The domain name still appears in the WHOIS database');
|
||||
throw new \InvalidArgumentException('The domain name still appears in the WHOIS database');
|
||||
}
|
||||
|
||||
$ldhName = $domain->getLdhName();
|
||||
if (!$ldhName) {
|
||||
throw new \Exception('Domain name cannot be null');
|
||||
throw new \InvalidArgumentException('Domain name cannot be null');
|
||||
}
|
||||
|
||||
$authData = self::verifyAuthData($this->authData, $this->client);
|
||||
@@ -91,7 +91,7 @@ class OvhProvider extends AbstractProvider
|
||||
);
|
||||
if (empty($offer)) {
|
||||
$conn->delete("/order/cart/{$cartId}");
|
||||
throw new \Exception('Cannot buy this domain name');
|
||||
throw new \InvalidArgumentException('Cannot buy this domain name');
|
||||
}
|
||||
|
||||
$item = $conn->post("/order/cart/{$cartId}/domain", [
|
||||
|
||||
@@ -10,6 +10,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\HttpClientInterface;
|
||||
@@ -67,7 +68,7 @@ class ConnectorController extends AbstractController
|
||||
]);
|
||||
|
||||
if (null === $provider) {
|
||||
throw new \Exception('Provider not found');
|
||||
throw new BadRequestHttpException('Provider not found');
|
||||
}
|
||||
|
||||
/** @var AbstractProvider $connectorProviderClass */
|
||||
|
||||
@@ -66,7 +66,7 @@ final readonly class OrderDomainHandler
|
||||
try {
|
||||
$provider = $connector->getProvider();
|
||||
if (null === $provider) {
|
||||
throw new \Exception('Provider not found');
|
||||
throw new \InvalidArgumentException('Provider not found');
|
||||
}
|
||||
|
||||
$connectorProviderClass = $provider->getConnectorProvider();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Notifier;
|
||||
|
||||
use App\Config\WebhookScheme;
|
||||
use App\Entity\Domain;
|
||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||
use Symfony\Component\Mime\Address;
|
||||
@@ -23,6 +24,8 @@ class DomainOrderErrorNotification extends DomainWatchdogNotification
|
||||
|
||||
public function asChatMessage(?RecipientInterface $recipient = null, ?string $transport = null): ?ChatMessage
|
||||
{
|
||||
$webhookScheme = WebhookScheme::from($transport);
|
||||
|
||||
$ldhName = $this->domain->getLdhName();
|
||||
$this->subject("Error: Domain Order $ldhName")
|
||||
->content("Domain name $ldhName tried to be purchased. The attempt failed.")
|
||||
@@ -41,7 +44,7 @@ class DomainOrderErrorNotification extends DomainWatchdogNotification
|
||||
return PushMessage::fromNotification($this);
|
||||
}
|
||||
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient, ?string $transport = null): EmailMessage
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient): EmailMessage
|
||||
{
|
||||
return new EmailMessage((new TemplatedEmail())
|
||||
->from($this->sender)
|
||||
|
||||
@@ -46,7 +46,7 @@ class DomainOrderNotification extends DomainWatchdogNotification
|
||||
return PushMessage::fromNotification($this);
|
||||
}
|
||||
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient, ?string $transport = null): EmailMessage
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient): EmailMessage
|
||||
{
|
||||
return new EmailMessage((new TemplatedEmail())
|
||||
->from($this->sender)
|
||||
|
||||
@@ -41,7 +41,7 @@ class DomainUpdateErrorNotification extends DomainWatchdogNotification
|
||||
return PushMessage::fromNotification($this);
|
||||
}
|
||||
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient, ?string $transport = null): EmailMessage
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient): EmailMessage
|
||||
{
|
||||
return new EmailMessage((new TemplatedEmail())
|
||||
->from($this->sender)
|
||||
|
||||
@@ -44,7 +44,7 @@ class DomainUpdateNotification extends DomainWatchdogNotification
|
||||
return PushMessage::fromNotification($this);
|
||||
}
|
||||
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient, ?string $transport = null): EmailMessage
|
||||
public function asEmailMessage(EmailRecipientInterface $recipient): EmailMessage
|
||||
{
|
||||
return new EmailMessage((new TemplatedEmail())
|
||||
->from($this->sender)
|
||||
|
||||
@@ -42,7 +42,7 @@ readonly class ChatNotificationService
|
||||
$transportFactory = new $transportFactoryClass();
|
||||
|
||||
$push = $notification->asPushMessage(new NoRecipient());
|
||||
$chat = $notification->asChatMessage(new NoRecipient());
|
||||
$chat = $notification->asChatMessage(new NoRecipient(), $webhookScheme->value);
|
||||
|
||||
try {
|
||||
$factory = $transportFactory->create($dsn);
|
||||
|
||||
Reference in New Issue
Block a user