Handled rename tag error from command

This commit is contained in:
Alejandro Celaya 2019-12-06 21:04:52 +01:00
parent 05451e3d1a
commit 27aa8f9875

View File

@ -6,6 +6,7 @@ namespace Shlinkio\Shlink\CLI\Command\Tag;
use Shlinkio\Shlink\CLI\Util\ExitCodes;
use Shlinkio\Shlink\Core\Exception\EntityDoesNotExistException;
use Shlinkio\Shlink\Core\Exception\TagConflictException;
use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@ -50,6 +51,11 @@ class RenameTagCommand extends Command
} catch (EntityDoesNotExistException $e) {
$io->error(sprintf('A tag with name "%s" was not found', $oldName));
return ExitCodes::EXIT_FAILURE;
} catch (TagConflictException $e) {
$io->error(
sprintf('A tag with name "%s" cannot be renamed to "%s" because it already exists', $oldName, $newName)
);
return ExitCodes::EXIT_FAILURE;
}
}
}