Skip to content

Commit

Permalink
use serializer exceptions in the context
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Apr 2, 2018
1 parent 2f65a4f commit 12b9241
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/Context.php
Expand Up @@ -18,6 +18,7 @@

namespace JMS\Serializer;

use JMS\Serializer\Exception\LogicException;
use JMS\Serializer\Exception\RuntimeException;
use JMS\Serializer\Exclusion\DepthExclusionStrategy;
use JMS\Serializer\Exclusion\DisjunctExclusionStrategy;
Expand Down Expand Up @@ -68,7 +69,7 @@ public function __construct()
public function initialize($format, VisitorInterface $visitor, GraphNavigatorInterface $navigator, MetadataFactoryInterface $factory)
{
if ($this->initialized) {
throw new \LogicException('This context was already initialized, and cannot be re-used.');
throw new LogicException('This context was already initialized, and cannot be re-used.');
}

$this->initialized = true;
Expand Down Expand Up @@ -134,7 +135,7 @@ private function assertMutable()
return;
}

throw new \LogicException('This context was already initialized and is immutable; you cannot modify it anymore.');
throw new LogicException('This context was already initialized and is immutable; you cannot modify it anymore.');
}

public function addExclusionStrategy(ExclusionStrategyInterface $strategy)
Expand Down Expand Up @@ -167,7 +168,7 @@ public function addExclusionStrategy(ExclusionStrategyInterface $strategy)
public function setVersion($version)
{
if (null === $version) {
throw new \LogicException('The version must not be null.');
throw new LogicException('The version must not be null.');
}

$this->attributes['version'] = $version;
Expand All @@ -182,7 +183,7 @@ public function setVersion($version)
public function setGroups($groups)
{
if (empty($groups)) {
throw new \LogicException('The groups must not be empty.');
throw new LogicException('The groups must not be empty.');
}

$this->attributes['groups'] = (array)$groups;
Expand Down
4 changes: 3 additions & 1 deletion src/DeserializationContext.php
Expand Up @@ -18,6 +18,8 @@

namespace JMS\Serializer;

use JMS\Serializer\Exception\LogicException;

class DeserializationContext extends Context
{
private $depth = 0;
Expand Down Expand Up @@ -45,7 +47,7 @@ public function increaseDepth()
public function decreaseDepth()
{
if ($this->depth <= 0) {
throw new \LogicException('Depth cannot be smaller than zero.');
throw new LogicException('Depth cannot be smaller than zero.');
}

$this->depth -= 1;
Expand Down

0 comments on commit 12b9241

Please sign in to comment.