mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-23 02:56:02 +02:00
Better error handling if missing cache file
This commit is contained in:
parent
6932ae28c5
commit
9070788a31
2 changed files with 20 additions and 2 deletions
|
@ -39,7 +39,13 @@ class DomainsController extends Controller
|
|||
}
|
||||
|
||||
$domainName = preg_replace('/[^\p{L}0-9-.]/u', '', $domainName);
|
||||
$parts = extractDomainAndTLD($domainName);
|
||||
try {
|
||||
$parts = extractDomainAndTLD($domainName);
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
$this->container->get('flash')->addMessage('error', "Error: " . $errorMessage);
|
||||
return $response->withHeader('Location', '/domain/check')->withStatus(302);
|
||||
}
|
||||
|
||||
$domainModel = new Domain($this->container->get('db'));
|
||||
$availability = $domainModel->getDomainByName($domainName);
|
||||
|
@ -163,7 +169,13 @@ class DomainsController extends Controller
|
|||
|
||||
$authInfo = $data['authInfo'] ?? null;
|
||||
|
||||
$parts = extractDomainAndTLD($domainName);
|
||||
try {
|
||||
$parts = extractDomainAndTLD($domainName);
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
$this->container->get('flash')->addMessage('error', "Error: " . $errorMessage);
|
||||
return $response->withHeader('Location', '/domain/create')->withStatus(302);
|
||||
}
|
||||
$label = $parts['domain'];
|
||||
$domain_extension = $parts['tld'];
|
||||
$invalid_domain = validate_label($domainName, $db);
|
||||
|
|
|
@ -288,6 +288,12 @@ function extractDomainAndTLD($urlString) {
|
|||
$cachedFile = $cache->getItem($cacheKey);
|
||||
$fileContent = $cachedFile->get();
|
||||
|
||||
// Check if fileContent is not null
|
||||
if (null === $fileContent) {
|
||||
// Handle the error gracefully
|
||||
throw new \Exception("The TLDs cache file is missing or unreadable");
|
||||
}
|
||||
|
||||
// Load a list of test TLDs used in your QA environment
|
||||
$testTlds = explode(',', envi('TEST_TLDS'));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue