Optimized Exceptions

This commit is contained in:
Kevin Frantz 2019-01-03 19:41:16 +01:00
parent 130682ef6c
commit 67428c2fea
10 changed files with 27 additions and 18 deletions

View File

@ -16,7 +16,7 @@ use App\Entity\Attribut\LayerAttribut;
use App\Entity\Attribut\RelationAttribut;
use App\Entity\Attribut\PriorityAttribut;
use App\Entity\Source\SourceInterface;
use App\Exception\NoValidChoice;
use App\Exception\NoValidChoiceException;
/**
* @author kevinfrantz
@ -100,7 +100,7 @@ class Right extends AbstractMeta implements RightInterface
public function setType(string $type): void
{
if (!array_key_exists($type, RightType::getChoices())) {
throw new NoValidChoice();
throw new NoValidChoiceException();
}
$this->type = $type;
}
@ -108,7 +108,7 @@ class Right extends AbstractMeta implements RightInterface
public function setLayer(string $layer): void
{
if (!array_key_exists($layer, LayerType::getChoices())) {
throw new NoValidChoice();
throw new NoValidChoiceException();
}
$this->layer = $layer;
}

View File

@ -0,0 +1,9 @@
<?php
namespace App\Exception;
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
final class AllreadySetException extends ConflictHttpException
{
}

View File

@ -1,7 +0,0 @@
<?php
namespace App\Exception;
class NoValidChoice extends \Exception
{
}

View File

@ -0,0 +1,7 @@
<?php
namespace App\Exception;
final class NoValidChoiceException extends \Exception
{
}

View File

@ -2,7 +2,7 @@
namespace App\Exception;
class NotDefinedException extends \Exception
final class NotDefinedException extends \Exception
{
public function __construct($message = null)
{

View File

@ -2,7 +2,7 @@
namespace App\Exception;
class NotProcessedException extends \Exception
final class NotProcessedException extends \Exception
{
public function __construct($message = null)
{

View File

@ -2,6 +2,6 @@
namespace App\Exception;
class NotSortableException extends \Exception
final class NotSortableException extends \Exception
{
}

View File

@ -2,6 +2,6 @@
namespace App\Exception;
class RecursiveException extends \Exception
final class RecursiveException extends \Exception
{
}

View File

@ -4,6 +4,6 @@ namespace App\Exception;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class SourceAccessDenied extends AccessDeniedHttpException
final class SourceAccessDenied extends AccessDeniedHttpException
{
}

View File

@ -8,7 +8,7 @@ use App\Entity\Meta\RightInterface;
use App\Entity\Meta\Right;
use App\Entity\Meta\Law;
use App\DBAL\Types\LayerType;
use App\Exception\NoValidChoice;
use App\Exception\NoValidChoiceException;
use App\Entity\Source\AbstractSource;
/**
@ -77,7 +77,7 @@ class RightTest extends TestCase
$this->assertNull($this->right->setType($key));
$this->assertEquals($key, $this->right->getType());
}
$this->expectException(NoValidChoice::class);
$this->expectException(NoValidChoiceException::class);
$this->right->setType('NoneValidType');
}
@ -87,7 +87,7 @@ class RightTest extends TestCase
$this->assertNull($this->right->setLayer($key));
$this->assertEquals($key, $this->right->getLayer());
}
$this->expectException(NoValidChoice::class);
$this->expectException(NoValidChoiceException::class);
$this->right->setLayer('NoneValidLayer');
}