From 263803c1d08dbbc0ced5b031426ecbd13242e180 Mon Sep 17 00:00:00 2001 From: Adam Kadlec Date: Tue, 24 Mar 2020 12:50:31 +0100 Subject: [PATCH] Extending create exception --- .../Exceptions/EntityCreationException.php | 27 +++++++++++++++++++ src/IPub/DoctrineCrud/Helpers.php | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/IPub/DoctrineCrud/Exceptions/EntityCreationException.php b/src/IPub/DoctrineCrud/Exceptions/EntityCreationException.php index 27c73ba..636dde9 100644 --- a/src/IPub/DoctrineCrud/Exceptions/EntityCreationException.php +++ b/src/IPub/DoctrineCrud/Exceptions/EntityCreationException.php @@ -18,4 +18,31 @@ class EntityCreationException extends \RuntimeException implements IException { + + /** + * @var string + */ + private $field; + + /** + * @param string $field + * @param string $message + * @param int $code + * @param \Exception|NULL $previous + */ + public function __construct(string $field, $message = '', $code = 0, \Exception $previous = null) + { + parent::__construct($message, $code, $previous); + + $this->field = $field; + } + + /** + * @return string + */ + public function getField(): string + { + return $this->field; + } + } diff --git a/src/IPub/DoctrineCrud/Helpers.php b/src/IPub/DoctrineCrud/Helpers.php index 570df13..7ded21b 100644 --- a/src/IPub/DoctrineCrud/Helpers.php +++ b/src/IPub/DoctrineCrud/Helpers.php @@ -83,7 +83,7 @@ public static function autowireArguments(ReflectionMethod $method, array $argume } } - throw new Exceptions\EntityCreationException("Parameter \${$parameter->getName()} in $methodName has no class type hint or default value, so its value must be specified."); + throw new Exceptions\EntityCreationException($parameter->getName(), "Parameter \${$parameter->getName()} in $methodName has no class type hint or default value, so its value must be specified."); } }