From e78b59fc4006a2f0e4f9c29b106a254be33cd597 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 1 Sep 2025 16:02:53 +0300 Subject: [PATCH] format function throw exception --- .../Functions/DatetimeGroup/FormatType.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/application/Espo/Core/Formula/Functions/DatetimeGroup/FormatType.php b/application/Espo/Core/Formula/Functions/DatetimeGroup/FormatType.php index 10b6ea0e30..ef7062d7c6 100644 --- a/application/Espo/Core/Formula/Functions/DatetimeGroup/FormatType.php +++ b/application/Espo/Core/Formula/Functions/DatetimeGroup/FormatType.php @@ -32,9 +32,10 @@ namespace Espo\Core\Formula\Functions\DatetimeGroup; use Espo\Core\Di; use Espo\Core\Formula\{ + Exceptions\Error, Functions\BaseFunction, - ArgumentList, -}; + ArgumentList}; +use RuntimeException; class FormatType extends BaseFunction implements Di\DateTimeAware { @@ -59,10 +60,14 @@ class FormatType extends BaseFunction implements Di\DateTimeAware $format = $args[2]; } - if (strlen($value) > 11) { - return $this->dateTime->convertSystemDateTime($value, $timezone, $format); - } else { - return $this->dateTime->convertSystemDate($value, $format); + try { + if (strlen($value) > 11) { + return $this->dateTime->convertSystemDateTime($value, $timezone, $format); + } else { + return $this->dateTime->convertSystemDate($value, $format); + } + } catch (RuntimeException $e) { + throw new Error($e->getMessage(), 500, $e); } } }