Skip to content

Commit

Permalink
bug #18645 [Console] Fix wrong exceptions being thrown (JhonnyL)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.8 branch.

Discussion
----------

[Console] Fix wrong exceptions being thrown

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

28fca7c [Console] Fix wrong exceptions being thrown
  • Loading branch information
nicolas-grekas committed Apr 27, 2016
2 parents 93a488b + 28fca7c commit f146f84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/Symfony/Component/Console/Helper/ProgressIndicator.php
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Component\Console\Helper;

use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Exception\LogicException;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -53,7 +55,7 @@ public function __construct(OutputInterface $output, $format = null, $indicatorC
$indicatorValues = array_values($indicatorValues);

if (2 > count($indicatorValues)) {
throw new \InvalidArgumentException('Must have at least 2 indicator value characters.');
throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
}

$this->format = self::getFormatDefinition($format);
Expand Down Expand Up @@ -118,7 +120,7 @@ public function getCurrentValue()
public function start($message)
{
if ($this->started) {
throw new \LogicException('Progress indicator already started.');
throw new LogicException('Progress indicator already started.');
}

$this->message = $message;
Expand All @@ -137,7 +139,7 @@ public function start($message)
public function advance()
{
if (!$this->started) {
throw new \LogicException('Progress indicator has not yet been started.');
throw new LogicException('Progress indicator has not yet been started.');
}

if (!$this->output->isDecorated()) {
Expand All @@ -164,7 +166,7 @@ public function advance()
public function finish($message)
{
if (!$this->started) {
throw new \LogicException('Progress indicator has not yet been started.');
throw new LogicException('Progress indicator has not yet been started.');
}

$this->message = $message;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Helper/Table.php
Expand Up @@ -162,7 +162,7 @@ public function setColumnStyle($columnIndex, $name)
} elseif (isset(self::$styles[$name])) {
$this->columnStyles[$columnIndex] = self::$styles[$name];
} else {
throw new \InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
}

return $this;
Expand Down

0 comments on commit f146f84

Please sign in to comment.