Skip to content

Commit

Permalink
Merge pull request #17 from netlogix/fix/check-if-site-is-available
Browse files Browse the repository at this point in the history
fix: Check if site is available before fetching error page
  • Loading branch information
toni-bessel authored Feb 26, 2024
2 parents 03340be + d15fe7e commit 1c722a3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Classes/Command/ErrorPageCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Neos\Utility\Files;
use Netlogix\ErrorHandler\Configuration\ErrorHandlerConfiguration;
use Netlogix\ErrorHandler\Service\ControllerContextFactory;
use RuntimeException;
use function dirname;
use function fopen;
use function is_dir;
Expand Down Expand Up @@ -84,6 +85,11 @@ public function generateCommand(bool $verbose = false)
foreach ($configurations as $configuration) {
$site = $this->siteRepository->findOneByNodeName($siteNodeName);
assert($site instanceof Site);

if (!$site->isOnline()) {
$verbose && $this->outputLine('Site %s is not online', [$siteNodeName]);
continue;
}
try {
$requestUri = $this->getSiteUri($site, $configuration);
} catch (\Exception $e) {
Expand Down Expand Up @@ -132,7 +138,7 @@ protected function getSiteUri(Site $site, array $configuration)
{
$domain = $site->getPrimaryDomain();
if (!$domain) {
$this->outputLine('Skipping %s as no primary domain is set.', [$site->getNodeName()]);
throw new RuntimeException(sprintf('Site %s has no primary domain', $site->getNodeName()), 1708944032);
}

$context = $this->getContextForSite($site, $domain, $configuration['dimensions']);
Expand Down

0 comments on commit 1c722a3

Please sign in to comment.