Skip to content

EspoCRM – Open Source CRM Application

before-save formula throw exception

Yurii9fddae6ffc76
diff --git a/application/Espo/Hooks/Common/Formula.php b/application/Espo/Hooks/Common/Formula.php
index 5888c217a4..ea1f7cfda1 100644
--- a/application/Espo/Hooks/Common/Formula.php
+++ b/application/Espo/Hooks/Common/Formula.php
@@ -30,10 +30,10 @@
namespace Espo\Hooks\Common;
use Espo\ORM\Entity;
+use Espo\ORM\Exceptions\PersistenceException;
use Espo\ORM\Repository\Option\SaveOptions;
use Espo\Core\Hook\Hook\BeforeSave;
use Espo\Core\Formula\Manager as FormulaManager;
-use Espo\Core\Utils\Log;
use Espo\Core\Utils\Metadata;
use Exception;
@@ -49,7 +49,6 @@ class Formula implements BeforeSave
public function __construct(
private Metadata $metadata,
private FormulaManager $formulaManager,
- private Log $log
) {}
public function beforeSave(Entity $entity, SaveOptions $options): void
@@ -80,10 +79,7 @@ class Formula implements BeforeSave
try {
$this->formulaManager->run($script, $entity, $variables);
} catch (Exception $e) {
- $this->log->critical('Before-save formula script failed. {message}', [
- 'message' => $e->getMessage(),
- 'exception' => $e,
- ]);
+ throw new PersistenceException("Before-save formula script failed.", previous: $e);
}
}
}