Skip to content

Commit

Permalink
Throw exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Apr 12, 2019
1 parent 95ea9e6 commit cfe467b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Command/CaptureScreenshotsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
return;
}

if (!$this->workflowRegistry instanceof Registry) {
throw new Exception('Can not capture screenshots: No workflows were defined');
}

if (!$this->filesystem instanceof Filesystem) {
throw new Exception("Can not capture screenshots: No filesystems with name 'mbt' were defined");
}

$this->setAnonymousToken();

$path = Path::unserialize($bug->getPath());
Expand Down
4 changes: 4 additions & 0 deletions src/Command/RemoveScreenshotsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$bugId = $input->getArgument('bug-id');
$model = $input->getArgument('model');

if (!$this->filesystem instanceof Filesystem) {
throw new Exception("Can not remove screenshots: No filesystems with name 'mbt' were defined");
}

$subject = $this->subjectManager->createSubject($model);
$subject->setFilesystem($this->filesystem);
$subject->removeScreenshots($bugId);
Expand Down
4 changes: 4 additions & 0 deletions src/Command/ReportBugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
throw new Exception("Can not report bug: No monolog's handlers with channel 'mbt' were defined");
}

if (!$this->filesystem instanceof Filesystem) {
throw new Exception("Can not report bug: No filesystems with name 'mbt' were defined");
}

$bugId = $input->getArgument('bug-id');

$callback = function () use ($bugId) {
Expand Down
5 changes: 5 additions & 0 deletions src/Maker/MakeSubject.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tienvx\Bundle\MbtBundle\Maker;

use Doctrine\Common\Annotations\Annotation;
use Exception;
use Symfony\Bundle\MakerBundle\ConsoleStyle;
use Symfony\Bundle\MakerBundle\DependencyBuilder;
use Symfony\Bundle\MakerBundle\Generator;
Expand Down Expand Up @@ -62,6 +63,10 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
*/
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
{
if (!$this->workflowRegistry instanceof Registry) {
throw new Exception('Can not make subject: No workflows were defined');
}

$model = $input->getArgument('model');
$workflow = WorkflowHelper::get($this->workflowRegistry, $model);

Expand Down
4 changes: 4 additions & 0 deletions src/PathReducer/AbstractPathReducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public function handle(int $bugId, int $length, int $from, int $to)
return;
}

if (!$this->workflowRegistry instanceof Registry) {
throw new Exception('Can not handle reduce path message: No workflows were defined');
}

$model = $bug->getTask()->getModel();
$workflow = WorkflowHelper::get($this->workflowRegistry, $model);

Expand Down

0 comments on commit cfe467b

Please sign in to comment.