- WIP on exceptions handling and throwing

This commit is contained in:
mcndave committed 2026-07-06 13:41:35 +00:00
1 parent 382a4459d7
commit 0443f5a811
6 files changed
+13 -7

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
<?php
namespace Lean\Api\Exception;
class LeanApiException extends \InvalidArgumentException {}
+1 -1
View File
@@ -2,4 +2,4 @@
namespace Lean\Api\Exception;
class MandatoryFieldException extends \InvalidArgumentException {}
class MandatoryFieldException extends LeanApiException {}
+1 -1
View File
@@ -2,4 +2,4 @@
namespace Lean\Api\Exception;
class MaximumLengthException extends \InvalidArgumentException {}
class MaximumLengthException extends LeanApiException {}
+1 -1
View File
@@ -2,4 +2,4 @@
namespace Lean\Api\Exception;
class MinimumLengthException extends \InvalidArgumentException {}
class MinimumLengthException extends LeanApiException {}
+1 -1
View File
@@ -2,4 +2,4 @@
namespace Lean\Api\Exception;
class RegexFormatException extends \InvalidArgumentException {}
class RegexFormatException extends LeanApiException{}
+4 -3
View File
@@ -6,7 +6,9 @@ use CSLSJ\Lean\Form\Session\EmailContext;
use Picea\Ui\Method\{FormContext, FormContextInterface};
use Lean\Api\Attribute\ContextField;
use Lean\Api\Exception\LeanApiException;
use Lean\Api\Exception\MandatoryFieldException;
use Lean\Api\Exception\MinimumLengthException;
use Notes\Common\ReflectedProperty;
use Notes\ObjectReflection;
use Ulmus\Attribute\Property\Field;
@@ -107,9 +109,8 @@ abstract class Save extends Form implements \Picea\Ui\Method\FormInterface {
if ($attribute) {
try {
$attribute->object->assertValueSpecs($context->$name ?? null, ! $this->getEntity()->isLoaded());
}
catch(\Throwable $ex) {
throw new MandatoryFieldException("An error occured with field '$name': " . $ex->getMessage());
} catch (LeanApiException $e) {
throw new MandatoryFieldException("An error occured with field '$name': " . $e->getMessage());
}
}
}