Skip to content

Commit

Permalink
[TASK] add better exception and use default value to avoid breaking DI
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkmann committed Dec 9, 2024
1 parent 94072e2 commit 6086e46
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function __construct(
private FrontendTypoScriptFactory $frontendTypoScriptFactory,
private ConnectionPool $connectionPool,
private SetRegistry $setRegistry,
private string $siteIdentifier,
private string $siteIdentifier = '',
) {}

/**
Expand Down Expand Up @@ -274,10 +274,12 @@ private function getCachedCurrentPageId(): int
*/
private function getCurrentPageId(): int
{
if($this->siteIdentifier === ''){
throw new \Exception('There is not site identifier provided. Please provide one via Service.yaml or Service.php. Read README.md for more help.', 1731170914);
}
$site = $this->siteFinder->getSiteByIdentifier($this->siteIdentifier);
if ($site instanceof NullSite) {
// @TODO better exception
throw new \Exception('Neine hier', 1731170913);
throw new \Exception('The site with identifier '.$this->siteIdentifier.' can not be found', 1731170913);
}
return $site->getRootPageId();
}
Expand Down

0 comments on commit 6086e46

Please sign in to comment.