From 5f7ca480676c2eee85971323813bfed38dac7152 Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 10 Sep 2025 12:24:24 +0300 Subject: [PATCH] try catch --- .../Platform/Workers/StatsResources.php | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index 98c9d01a87..da8c086bf4 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -432,11 +432,20 @@ class StatsResources extends Action protected function writeDocuments(Database $dbForLogs, Document $project): void { - $dbForLogs->createOrUpdateDocuments( - 'stats', - $this->documents - ); - $this->documents = []; - Console::success('Stats written to logs db for project: ' . $project->getId() . '(' . $project->getSequence() . ')'); + $message = 'Stats writeDocuments project: ' . $project->getId() . '(' . $project->getSequence() . ')'; + + try { + $dbForLogs->createOrUpdateDocuments( + 'stats', + $this->documents + ); + + Console::success($message . ' | Documents: ' . count($this->documents)); + } catch (\Throwable $e) { + Console::error('Error: ' . $message . ' | Exception: ' . $e->getMessage()); + throw $e; + } finally { + $this->documents = []; + } } }