Files
shlink/module/Core/src/Exception/ShortUrlNotFoundException.php

32 lines
874 B
PHP
Raw Normal View History

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
use Fig\Http\Message\StatusCodeInterface;
use Zend\ProblemDetails\Exception\CommonProblemDetailsExceptionTrait;
use Zend\ProblemDetails\Exception\ProblemDetailsExceptionInterface;
use function sprintf;
class ShortUrlNotFoundException extends DomainException implements ProblemDetailsExceptionInterface
2016-04-17 13:42:52 +02:00
{
use CommonProblemDetailsExceptionTrait;
private const TITLE = 'Short URL not found';
public const TYPE = 'INVALID_SHORTCODE';
2018-11-17 19:23:25 +01:00
public static function fromNotFoundShortCode(string $shortCode): self
{
$e = new self(sprintf('No URL found for short code "%s"', $shortCode));
$e->detail = $e->getMessage();
$e->title = self::TITLE;
$e->type = self::TYPE;
$e->status = StatusCodeInterface::STATUS_NOT_FOUND;
return $e;
}
2016-04-17 13:42:52 +02:00
}