mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Added logic to properly map all existing errors from v3 to v2 in the API
This commit is contained in:
@@ -16,7 +16,7 @@ class DeleteShortUrlException extends DomainException implements ProblemDetailsE
|
||||
use CommonProblemDetailsExceptionTrait;
|
||||
|
||||
private const TITLE = 'Cannot delete short URL';
|
||||
private const TYPE = 'INVALID_SHORT_URL_DELETION';
|
||||
public const TYPE = 'https://shlink.io/api/error/invalid-short-url-deletion';
|
||||
|
||||
public static function fromVisitsThreshold(int $threshold, ShortUrlIdentifier $identifier): self
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ class DomainNotFoundException extends DomainException implements ProblemDetailsE
|
||||
use CommonProblemDetailsExceptionTrait;
|
||||
|
||||
private const TITLE = 'Domain not found';
|
||||
private const TYPE = 'DOMAIN_NOT_FOUND';
|
||||
public const TYPE = 'https://shlink.io/api/error/domain-not-found';
|
||||
|
||||
private function __construct(string $message, array $additional)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ class ForbiddenTagOperationException extends DomainException implements ProblemD
|
||||
use CommonProblemDetailsExceptionTrait;
|
||||
|
||||
private const TITLE = 'Forbidden tag operation';
|
||||
private const TYPE = 'FORBIDDEN_OPERATION';
|
||||
public const TYPE = 'https://shlink.io/api/error/forbidden-tag-operation';
|
||||
|
||||
public static function forDeletion(): self
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ class InvalidUrlException extends DomainException implements ProblemDetailsExcep
|
||||
use CommonProblemDetailsExceptionTrait;
|
||||
|
||||
private const TITLE = 'Invalid URL';
|
||||
private const TYPE = 'INVALID_URL';
|
||||
public const TYPE = 'https://shlink.io/api/error/invalid-url';
|
||||
|
||||
public static function fromUrl(string $url, ?Throwable $previous = null): self
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ class NonUniqueSlugException extends InvalidArgumentException implements Problem
|
||||
use CommonProblemDetailsExceptionTrait;
|
||||
|
||||
private const TITLE = 'Invalid custom slug';
|
||||
private const TYPE = 'INVALID_SLUG';
|
||||
public const TYPE = 'https://shlink.io/api/error/non-unique-slug';
|
||||
|
||||
public static function fromSlug(string $slug, ?string $domain = null): self
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ class ShortUrlNotFoundException extends DomainException implements ProblemDetail
|
||||
use CommonProblemDetailsExceptionTrait;
|
||||
|
||||
private const TITLE = 'Short URL not found';
|
||||
private const TYPE = 'INVALID_SHORTCODE';
|
||||
public const TYPE = 'https://shlink.io/api/error/short-url-not-found';
|
||||
|
||||
public static function fromNotFound(ShortUrlIdentifier $identifier): self
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ class TagConflictException extends RuntimeException implements ProblemDetailsExc
|
||||
use CommonProblemDetailsExceptionTrait;
|
||||
|
||||
private const TITLE = 'Tag conflict';
|
||||
private const TYPE = 'TAG_CONFLICT';
|
||||
public const TYPE = 'https://shlink.io/api/error/tag-conflict';
|
||||
|
||||
public static function forExistingTag(TagRenaming $renaming): self
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ class TagNotFoundException extends DomainException implements ProblemDetailsExce
|
||||
use CommonProblemDetailsExceptionTrait;
|
||||
|
||||
private const TITLE = 'Tag not found';
|
||||
private const TYPE = 'TAG_NOT_FOUND';
|
||||
public const TYPE = 'https://shlink.io/api/error/tag-not-found';
|
||||
|
||||
public static function fromTag(string $tag): self
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ class DeleteShortUrlExceptionTest extends TestCase
|
||||
'threshold' => $threshold,
|
||||
], $e->getAdditionalData());
|
||||
self::assertEquals('Cannot delete short URL', $e->getTitle());
|
||||
self::assertEquals('INVALID_SHORT_URL_DELETION', $e->getType());
|
||||
self::assertEquals('https://shlink.io/api/error/invalid-short-url-deletion', $e->getType());
|
||||
self::assertEquals(422, $e->getStatus());
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class DomainNotFoundExceptionTest extends TestCase
|
||||
self::assertEquals($expectedMessage, $e->getMessage());
|
||||
self::assertEquals($expectedMessage, $e->getDetail());
|
||||
self::assertEquals('Domain not found', $e->getTitle());
|
||||
self::assertEquals('DOMAIN_NOT_FOUND', $e->getType());
|
||||
self::assertEquals('https://shlink.io/api/error/domain-not-found', $e->getType());
|
||||
self::assertEquals(['id' => $id], $e->getAdditionalData());
|
||||
self::assertEquals(404, $e->getStatus());
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class DomainNotFoundExceptionTest extends TestCase
|
||||
self::assertEquals($expectedMessage, $e->getMessage());
|
||||
self::assertEquals($expectedMessage, $e->getDetail());
|
||||
self::assertEquals('Domain not found', $e->getTitle());
|
||||
self::assertEquals('DOMAIN_NOT_FOUND', $e->getType());
|
||||
self::assertEquals('https://shlink.io/api/error/domain-not-found', $e->getType());
|
||||
self::assertEquals(['authority' => $authority], $e->getAdditionalData());
|
||||
self::assertEquals(404, $e->getStatus());
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class ForbiddenTagOperationExceptionTest extends TestCase
|
||||
self::assertEquals($expectedMessage, $e->getMessage());
|
||||
self::assertEquals($expectedMessage, $e->getDetail());
|
||||
self::assertEquals('Forbidden tag operation', $e->getTitle());
|
||||
self::assertEquals('FORBIDDEN_OPERATION', $e->getType());
|
||||
self::assertEquals('https://shlink.io/api/error/forbidden-tag-operation', $e->getType());
|
||||
self::assertEquals(403, $e->getStatus());
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class InvalidUrlExceptionTest extends TestCase
|
||||
self::assertEquals($expectedMessage, $e->getMessage());
|
||||
self::assertEquals($expectedMessage, $e->getDetail());
|
||||
self::assertEquals('Invalid URL', $e->getTitle());
|
||||
self::assertEquals('INVALID_URL', $e->getType());
|
||||
self::assertEquals('https://shlink.io/api/error/invalid-url', $e->getType());
|
||||
self::assertEquals(['url' => $url], $e->getAdditionalData());
|
||||
self::assertEquals(StatusCodeInterface::STATUS_BAD_REQUEST, $e->getCode());
|
||||
self::assertEquals(StatusCodeInterface::STATUS_BAD_REQUEST, $e->getStatus());
|
||||
|
||||
@@ -25,7 +25,7 @@ class NonUniqueSlugExceptionTest extends TestCase
|
||||
self::assertEquals($expectedMessage, $e->getMessage());
|
||||
self::assertEquals($expectedMessage, $e->getDetail());
|
||||
self::assertEquals('Invalid custom slug', $e->getTitle());
|
||||
self::assertEquals('INVALID_SLUG', $e->getType());
|
||||
self::assertEquals('https://shlink.io/api/error/non-unique-slug', $e->getType());
|
||||
self::assertEquals(400, $e->getStatus());
|
||||
self::assertEquals($expectedAdditional, $e->getAdditionalData());
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class ShortUrlNotFoundExceptionTest extends TestCase
|
||||
self::assertEquals($expectedMessage, $e->getMessage());
|
||||
self::assertEquals($expectedMessage, $e->getDetail());
|
||||
self::assertEquals('Short URL not found', $e->getTitle());
|
||||
self::assertEquals('INVALID_SHORTCODE', $e->getType());
|
||||
self::assertEquals('https://shlink.io/api/error/short-url-not-found', $e->getType());
|
||||
self::assertEquals(404, $e->getStatus());
|
||||
self::assertEquals($expectedAdditional, $e->getAdditionalData());
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class TagConflictExceptionTest extends TestCase
|
||||
self::assertEquals($expectedMessage, $e->getMessage());
|
||||
self::assertEquals($expectedMessage, $e->getDetail());
|
||||
self::assertEquals('Tag conflict', $e->getTitle());
|
||||
self::assertEquals('TAG_CONFLICT', $e->getType());
|
||||
self::assertEquals('https://shlink.io/api/error/tag-conflict', $e->getType());
|
||||
self::assertEquals(['oldName' => $oldName, 'newName' => $newName], $e->getAdditionalData());
|
||||
self::assertEquals(409, $e->getStatus());
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class TagNotFoundExceptionTest extends TestCase
|
||||
self::assertEquals($expectedMessage, $e->getMessage());
|
||||
self::assertEquals($expectedMessage, $e->getDetail());
|
||||
self::assertEquals('Tag not found', $e->getTitle());
|
||||
self::assertEquals('TAG_NOT_FOUND', $e->getType());
|
||||
self::assertEquals('https://shlink.io/api/error/tag-not-found', $e->getType());
|
||||
self::assertEquals(['tag' => $tag], $e->getAdditionalData());
|
||||
self::assertEquals(404, $e->getStatus());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user