Skip to content

Commit

Permalink
Added error-handling during qualification
Browse files Browse the repository at this point in the history
  • Loading branch information
jekuaitk committed Oct 18, 2024
1 parent 00c49a4 commit 56729b1
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ public function givDinStemmeQualify($options = ['re-qualify' => FALSE]): void {
foreach ($gdsEntities as $gds) {
$this->io()->writeln('Handling donation ' . $counter . ' of ' . $numberOfGds);

$this->qualifyGivDinStemme($gds);
try {
$this->qualifyGivDinStemme($gds);
}
catch (\Exception $exception) {
$this->logger()->log('error', $exception->getMessage());
$this->io->writeln('Failed qualifying donation with id: ' . $gds->id() . '. Continuing...');
}

$counter++;
}
Expand All @@ -120,15 +126,23 @@ public function qualifyById($id = 1): void {

foreach ($donations as $donation) {

// Although this would get caught by the subsequent try-catch,
// we explicitly handle this to help the user.
if (!$donation->getFile()) {
$this->io()->error(sprintf('Donation with id %d does not have an attached donation file.', $id));
return;
}

$this->qualifyGivDinStemme($donation);
}
try {
$this->qualifyGivDinStemme($donation);
$this->io->success('Finished qualifying');
}
catch (\Exception $exception) {
$this->logger()->log('error', $exception->getMessage());
$this->io->error('Failed qualifying donation with id: ' . $donation->id());
}

$this->io->success('Finished qualifying donations');
}
}

/**
Expand Down

0 comments on commit 56729b1

Please sign in to comment.