2016-04-17 13:42:52 +02:00
|
|
|
<?php
|
2019-10-05 17:26:10 +02:00
|
|
|
|
2017-10-12 10:13:20 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2016-07-19 18:01:39 +02:00
|
|
|
namespace Shlinkio\Shlink\Core\Exception;
|
2016-04-17 13:42:52 +02:00
|
|
|
|
2019-11-23 13:41:07 +01:00
|
|
|
use Fig\Http\Message\StatusCodeInterface;
|
|
|
|
|
use Zend\ProblemDetails\Exception\CommonProblemDetailsExceptionTrait;
|
|
|
|
|
use Zend\ProblemDetails\Exception\ProblemDetailsExceptionInterface;
|
2019-02-26 22:56:43 +01:00
|
|
|
|
2018-10-28 08:24:06 +01:00
|
|
|
use function sprintf;
|
|
|
|
|
|
2019-11-24 23:11:25 +01:00
|
|
|
class ShortUrlNotFoundException extends DomainException implements ProblemDetailsExceptionInterface
|
2016-04-17 13:42:52 +02:00
|
|
|
{
|
2019-11-23 13:41:07 +01:00
|
|
|
use CommonProblemDetailsExceptionTrait;
|
|
|
|
|
|
2019-11-24 23:11:25 +01:00
|
|
|
private const TITLE = 'Short URL not found';
|
2019-11-23 13:41:07 +01:00
|
|
|
public const TYPE = 'INVALID_SHORTCODE';
|
2016-08-21 16:52:26 +02:00
|
|
|
|
2018-11-17 19:23:25 +01:00
|
|
|
public static function fromNotFoundShortCode(string $shortCode): self
|
2016-08-21 16:52:26 +02:00
|
|
|
{
|
2019-11-23 13:41:07 +01:00
|
|
|
$e = new self(sprintf('No URL found for short code "%s"', $shortCode));
|
2019-11-24 12:41:12 +01:00
|
|
|
|
2019-11-23 13:41:07 +01:00
|
|
|
$e->detail = $e->getMessage();
|
|
|
|
|
$e->title = self::TITLE;
|
|
|
|
|
$e->type = self::TYPE;
|
|
|
|
|
$e->status = StatusCodeInterface::STATUS_NOT_FOUND;
|
|
|
|
|
|
|
|
|
|
return $e;
|
2016-08-21 16:52:26 +02:00
|
|
|
}
|
2016-04-17 13:42:52 +02:00
|
|
|
}
|