Skip to content

Commit

Permalink
Change exception type in ContentBlock::fromArray()
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed May 7, 2018
1 parent 58db31a commit 68428a7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions system/src/Grav/Framework/ContentBlock/ContentBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static function create($id = null)
/**
* @param array $serialized
* @return ContentBlockInterface
* @throws \InvalidArgumentException
*/
public static function fromArray(array $serialized)
{
Expand All @@ -49,14 +50,14 @@ public static function fromArray(array $serialized)
$id = isset($serialized['id']) ? $serialized['id'] : null;

if (!$type || !$id || !is_a($type, 'Grav\Framework\ContentBlock\ContentBlockInterface', true)) {
throw new \RuntimeException('Bad data');
throw new \InvalidArgumentException('Bad data');
}

/** @var ContentBlockInterface $instance */
$instance = new $type($id);
$instance->build($serialized);
} catch (\Exception $e) {
throw new \RuntimeException(sprintf('Cannot unserialize Block: %s', $e->getMessage()), $e->getCode(), $e);
throw new \InvalidArgumentException(sprintf('Cannot unserialize Block: %s', $e->getMessage()), $e->getCode(), $e);
}

return $instance;
Expand Down

0 comments on commit 68428a7

Please sign in to comment.