mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-12 01:54:41 +08:00
Centralized prefix for problem detail types
This commit is contained in:
@@ -15,6 +15,9 @@ use Shlinkio\Shlink\Core\Exception\TagConflictException;
|
||||
use Shlinkio\Shlink\Core\Exception\TagNotFoundException;
|
||||
use Shlinkio\Shlink\Core\Exception\ValidationException;
|
||||
|
||||
use function explode;
|
||||
use function Functional\last;
|
||||
|
||||
/** @deprecated */
|
||||
class BackwardsCompatibleProblemDetailsException extends RuntimeException implements ProblemDetailsExceptionInterface
|
||||
{
|
||||
@@ -74,19 +77,20 @@ class BackwardsCompatibleProblemDetailsException extends RuntimeException implem
|
||||
|
||||
private function remapType(string $wrappedType): string
|
||||
{
|
||||
return match ($wrappedType) {
|
||||
ValidationException::TYPE => 'INVALID_ARGUMENT',
|
||||
DeleteShortUrlException::TYPE => 'INVALID_SHORT_URL_DELETION',
|
||||
DomainNotFoundException::TYPE => 'DOMAIN_NOT_FOUND',
|
||||
ForbiddenTagOperationException::TYPE => 'FORBIDDEN_OPERATION',
|
||||
InvalidUrlException::TYPE => 'INVALID_URL',
|
||||
NonUniqueSlugException::TYPE => 'INVALID_SLUG',
|
||||
ShortUrlNotFoundException::TYPE => 'INVALID_SHORTCODE',
|
||||
TagConflictException::TYPE => 'TAG_CONFLICT',
|
||||
TagNotFoundException::TYPE => 'TAG_NOT_FOUND',
|
||||
MercureException::TYPE => 'MERCURE_NOT_CONFIGURED',
|
||||
MissingAuthenticationException::TYPE => 'INVALID_AUTHORIZATION',
|
||||
VerifyAuthenticationException::TYPE => 'INVALID_API_KEY',
|
||||
$lastSegment = last(explode('/', $wrappedType));
|
||||
return match ($lastSegment) {
|
||||
ValidationException::ERROR_CODE => 'INVALID_ARGUMENT',
|
||||
DeleteShortUrlException::ERROR_CODE => 'INVALID_SHORT_URL_DELETION',
|
||||
DomainNotFoundException::ERROR_CODE => 'DOMAIN_NOT_FOUND',
|
||||
ForbiddenTagOperationException::ERROR_CODE => 'FORBIDDEN_OPERATION',
|
||||
InvalidUrlException::ERROR_CODE => 'INVALID_URL',
|
||||
NonUniqueSlugException::ERROR_CODE => 'INVALID_SLUG',
|
||||
ShortUrlNotFoundException::ERROR_CODE => 'INVALID_SHORTCODE',
|
||||
TagConflictException::ERROR_CODE => 'TAG_CONFLICT',
|
||||
TagNotFoundException::ERROR_CODE => 'TAG_NOT_FOUND',
|
||||
MercureException::ERROR_CODE => 'MERCURE_NOT_CONFIGURED',
|
||||
MissingAuthenticationException::ERROR_CODE => 'INVALID_AUTHORIZATION',
|
||||
VerifyAuthenticationException::ERROR_CODE => 'INVALID_API_KEY',
|
||||
default => $wrappedType,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user