forked from mirror/Part-DB.Part-DB-server
Throw an exception message, when trying to use an info provider which is not active
This commit is contained in:
parent
9b35b60d61
commit
085adf8d71
1 changed files with 10 additions and 0 deletions
|
@ -59,6 +59,11 @@ final class PartInfoRetriever
|
|||
$provider = $this->provider_registry->getProviderByKey($provider);
|
||||
}
|
||||
|
||||
//Ensure that the provider is active
|
||||
if (!$provider->isActive()) {
|
||||
throw new \RuntimeException("The provider with key {$provider->getProviderKey()} is not active!");
|
||||
}
|
||||
|
||||
if (!$provider instanceof InfoProviderInterface) {
|
||||
throw new \InvalidArgumentException("The provider must be either a provider key or a provider instance!");
|
||||
}
|
||||
|
@ -97,6 +102,11 @@ final class PartInfoRetriever
|
|||
{
|
||||
$provider = $this->provider_registry->getProviderByKey($provider_key);
|
||||
|
||||
//Ensure that the provider is active
|
||||
if (!$provider->isActive()) {
|
||||
throw new \RuntimeException("The provider with key $provider_key is not active!");
|
||||
}
|
||||
|
||||
//Generate key and escape reserved characters from the provider id
|
||||
$escaped_part_id = urlencode($part_id);
|
||||
return $this->partInfoCache->get("details_{$provider_key}_{$escaped_part_id}", function (ItemInterface $item) use ($provider, $part_id) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue