Skip to content

Commit 085adf8

Browse files
committed
Throw an exception message, when trying to use an info provider which is not active
1 parent 9b35b60 commit 085adf8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Services/InfoProviderSystem/PartInfoRetriever.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ public function searchByKeyword(string $keyword, array $providers): array
5959
$provider = $this->provider_registry->getProviderByKey($provider);
6060
}
6161

62+
//Ensure that the provider is active
63+
if (!$provider->isActive()) {
64+
throw new \RuntimeException("The provider with key {$provider->getProviderKey()} is not active!");
65+
}
66+
6267
if (!$provider instanceof InfoProviderInterface) {
6368
throw new \InvalidArgumentException("The provider must be either a provider key or a provider instance!");
6469
}
@@ -97,6 +102,11 @@ public function getDetails(string $provider_key, string $part_id): PartDetailDTO
97102
{
98103
$provider = $this->provider_registry->getProviderByKey($provider_key);
99104

105+
//Ensure that the provider is active
106+
if (!$provider->isActive()) {
107+
throw new \RuntimeException("The provider with key $provider_key is not active!");
108+
}
109+
100110
//Generate key and escape reserved characters from the provider id
101111
$escaped_part_id = urlencode($part_id);
102112
return $this->partInfoCache->get("details_{$provider_key}_{$escaped_part_id}", function (ItemInterface $item) use ($provider, $part_id) {

0 commit comments

Comments
 (0)