refactor: add custom Exception class

This commit is contained in:
Maël Gangloff
2025-10-07 15:55:17 +02:00
parent 79589e63eb
commit ea1df9d97a
10 changed files with 109 additions and 37 deletions

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Exception;
class DomainNotFoundException extends \Exception
{
public static function fromDomain(string $ldhName): DomainNotFoundException
{
return new DomainNotFoundException("The domain name $ldhName is not present in the WHOIS database");
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Exception;
class MalformedDomainException extends \Exception
{
public static function fromDomain(string $ldhName): MalformedDomainException
{
return new MalformedDomainException("Domain name ($ldhName) must contain at least one dot");
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Exception;
class TldNotSupportedException extends \Exception
{
public static function fromTld(string $tld): TldNotSupportedException
{
return new TldNotSupportedException("The requested TLD $tld is not yet supported, please try again with another one");
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Exception;
class UnknownRdapServerException extends \Exception
{
public static function fromTld(string $tld): UnknownRdapServerException
{
return new UnknownRdapServerException("TLD $tld: Unable to determine which RDAP server to contact");
}
}