Skip to content

Commit

Permalink
Use Info::isValid() to verify src and/or error images instead of catch()
Browse files Browse the repository at this point in the history
  • Loading branch information
GwendolenLynch committed Jun 4, 2017
1 parent 79f6d57 commit 42b64ad
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/Creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,18 @@ public function create(Transaction $transaction)
*/
protected function verifyInfo(Transaction $transaction)
{
try {
$transaction->getSrcImage()->getInfo();

if ($transaction->getSrcImage()->getInfo()->isValid()) {
return;
} catch (IOException $e) {
}

$transaction->setSrcImage($transaction->getErrorImage());
try {
$transaction->getSrcImage()->getInfo();
} catch (IOException $e) {
throw new RuntimeException(
'There was an error with the thumbnail image requested and additionally the fallback image could not be displayed.',
1,
$e
);
if ($transaction->getSrcImage()->getInfo()->isValid()) {
return;
}

throw new RuntimeException(
'There was an error with the thumbnail image requested and additionally the fallback image could not be displayed.',
1
);
}

/**
Expand Down

0 comments on commit 42b64ad

Please sign in to comment.