From c820404856f15f134fd3771177dc00a3280d9fb7 Mon Sep 17 00:00:00 2001 From: hansemschnokeloch Date: Thu, 12 Feb 2026 16:42:55 +0100 Subject: [PATCH] Error handling methods for commonobject (#37201) --- htdocs/core/class/commonobject.class.php | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a6933803b2b..42a68df7303 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -11705,4 +11705,29 @@ abstract class CommonObject return true; } } + + /** + * Set the error message for the object without logging it. + * + * @param string $message the error message + * @return void + */ + public function setErrorWithoutLog($message) + { + $this->error = $message; + $this->errors[] = $message; + } + + /** + * Set the error message for the object and log it. + * + * @param string $message the error message + * @param int<0,7> $loglevel the log level + * @return void + */ + public function setErrorWithLog($message, $loglevel = LOG_ERR) + { + $this->setErrorWithoutLog($message); + dol_syslog($message, $loglevel); + } }