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

23 lines
668 B
PHP
Raw Normal View History

2016-04-17 13:42:52 +02:00
<?php
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
class InvalidShortCodeException extends RuntimeException
{
public static function fromCharset($shortCode, $charSet, \Exception $previous = null)
2016-04-17 13:42:52 +02:00
{
$code = $previous !== null ? $previous->getCode() : -1;
2016-04-17 13:42:52 +02:00
return new static(
\sprintf('Provided short code "%s" does not match the char set "%s"', $shortCode, $charSet),
2016-04-17 13:42:52 +02:00
$code,
$previous
);
}
public static function fromNotFoundShortCode($shortCode)
{
return new static(\sprintf('Provided short code "%s" does not belong to a short URL', $shortCode));
}
2016-04-17 13:42:52 +02:00
}