Skip to content

Commit

Permalink
feat: throw compatible exception when available
Browse files Browse the repository at this point in the history
  • Loading branch information
hschoenenberger committed Dec 24, 2024
1 parent ec73f38 commit b270145
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"ramsey/uuid": "^3.9",
"prestashopcorp/oauth2-prestashop": "^2.0",
"guzzlehttp/guzzle": "^6.0",
"prestashopcorp/lightweight-container": "dev-main"
"prestashopcorp/lightweight-container": "v0.1.0"
},
"repositories": [
{
Expand All @@ -60,4 +60,4 @@
}
],
"author": "PrestaShop"
}
}
31 changes: 14 additions & 17 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion ps_accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,14 @@ public function getServiceContainer()
*/
public function getService($serviceName)
{
return $this->getServiceContainer()->getService($serviceName);
try {
return $this->getServiceContainer()->getService($serviceName);
} catch (\PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\Exception\ServiceNotFoundException $e) {
if (class_exists('\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException')) {
throw new \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($serviceName);
}
throw $e;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceContainer/PsAccountsContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getLogger()
{
if (null === $this->logger) {
$this->logger = LoggerFactory::create(
$this->getParameterWithDefault(
$this->getParameter(
'ps_accounts.log_level',
LoggerFactory::ERROR
)
Expand Down

0 comments on commit b270145

Please sign in to comment.