Make error more specific

Signed-off-by: Vitor Mattos <vitor@php.rio>
This commit is contained in:
Vitor Mattos
2021-09-17 06:42:06 -03:00
committed by Julius Härtl
parent a3959e3cfc
commit 24c8b2f4aa

View File

@@ -80,17 +80,18 @@ class BoardImportCommandService extends BoardImportService {
$config = $this->getInput()->getOption('config'); $config = $this->getInput()->getOption('config');
if (is_string($config)) { if (is_string($config)) {
if (!is_file($config)) { if (!is_file($config)) {
throw new NotFoundException('Please inform a valid config json file'); throw new NotFoundException('It\'s not a file.');
} }
$config = json_decode(file_get_contents($config)); $config = json_decode(file_get_contents($config));
if (!$config instanceof \stdClass) { if (!$config instanceof \stdClass) {
throw new NotFoundException('Please inform a valid config json file'); throw new NotFoundException('Failed to parse JSON.');
} }
$this->setConfigInstance($config); $this->setConfigInstance($config);
} }
parent::validateConfig(); parent::validateConfig();
return; return;
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
$this->getOutput()->writeln('<error>' . $e->getMessage() . '</error>');
$helper = $this->getCommand()->getHelper('question'); $helper = $this->getCommand()->getHelper('question');
$question = new Question( $question = new Question(
'Please inform a valid config json file: ', 'Please inform a valid config json file: ',