Skip to content

Commit

Permalink
Throw exceptions instead of dying
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Richter committed Nov 4, 2024
1 parent f018a89 commit 6756072
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Classes/Command/IndexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ protected function configure(): void
'The version number of the most recently updated data set.'
)->
addOption(
'total',
't',
InputOption::VALUE_REQUIRED,
'Limit the total number of results for dev purposes and force fullSync.'
)->
'total',
't',
InputOption::VALUE_REQUIRED,
'Limit the total number of results for dev purposes and force fullSync.'
)->
addOption(
'all',
'a',
Expand Down Expand Up @@ -155,7 +155,7 @@ protected function fullSync(InputInterface $input): void
} else {
$this->io->error("Exception: " . $e->getMessage());
$this->logger->error('Bibliography sync unsuccessful. Error creating elasticsearch index.');
die;
throw new \Exception('Bibliography sync unsuccessful.');
}
}

Expand All @@ -177,7 +177,7 @@ protected function fullSync(InputInterface $input): void
if ($apiCounter == 0) {
$this->io->note('Giving up after ' . self::API_TRIALS . ' trials.');
$this->logger->error('Bibliography sync unsuccessful. Zotero API sent {trials} 500 errors.', ['trials' => self::API_TRIALS]);
die;
throw new \Exception('Bibliography sync unsuccessful.');
} else {
$this->io->note('Trying again. ' . --$apiCounter . ' trials left.');
}
Expand All @@ -200,8 +200,8 @@ protected function versionedSync(int $version): void
$this->io->newline(1);
if ($apiCounter == 0) {
$this->io->note('Giving up after ' . self::API_TRIALS . ' trials.');
$this->logger->warning('Bibliography sync unseccessful. Zotero API sent {trials} 500 errors.', ['trials' => self::API_TRIALS]);
die; // Todo: die ist not recommended, better throw an exception?
$this->logger->warning('Bibliography sync unsuccessful. Zotero API sent {trials} 500 errors.', ['trials' => self::API_TRIALS]);
throw new \Exception('Bibliography sync unsuccessful.');
} else {
$this->io->note('Trying again. ' . --$apiCounter . ' trials left.');
}
Expand Down Expand Up @@ -263,7 +263,7 @@ protected function getVersion(InputInterface $input): int
return 0;
} else {
$this->io->error("Exception: " . $e->getMessage());
die; // Todo: die ist not recommended, better throw an exception?
throw new \Exception('Bibliography sync unsuccessful.');
}
}
}
Expand Down

0 comments on commit 6756072

Please sign in to comment.