Use more meaningful domain exceptions to represent ApiKeyService thrown errors

This commit is contained in:
Alejandro Celaya
2024-11-18 09:51:27 +01:00
parent b11d5c6864
commit 8298ef36f8
5 changed files with 66 additions and 21 deletions

View File

@@ -8,6 +8,8 @@ use Shlinkio\Shlink\Common\Exception\InvalidArgumentException;
use Shlinkio\Shlink\Core\Model\Renaming;
use Shlinkio\Shlink\Rest\ApiKey\Model\ApiKeyMeta;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
use Shlinkio\Shlink\Rest\Exception\ApiKeyConflictException;
use Shlinkio\Shlink\Rest\Exception\ApiKeyNotFoundException;
interface ApiKeyServiceInterface
{
@@ -21,13 +23,13 @@ interface ApiKeyServiceInterface
public function check(string $key): ApiKeyCheckResult;
/**
* @throws InvalidArgumentException
* @throws ApiKeyNotFoundException
*/
public function disableByName(string $apiKeyName): ApiKey;
/**
* @deprecated Use `self::disableByName($name)` instead
* @throws InvalidArgumentException
* @throws ApiKeyNotFoundException
*/
public function disableByKey(string $key): ApiKey;
@@ -37,7 +39,8 @@ interface ApiKeyServiceInterface
public function listKeys(bool $enabledOnly = false): array;
/**
* @throws InvalidArgumentException If an API key with oldName does not exist, or newName is in use by another one
* @throws ApiKeyNotFoundException
* @throws ApiKeyConflictException
*/
public function renameApiKey(Renaming $apiKeyRenaming): ApiKey;
}