try catch

This commit is contained in:
fogelito 2025-09-10 12:24:24 +03:00
parent 1f04104d7e
commit 5f7ca48067

View file

@ -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 = [];
}
}
}