mirror of
https://github.com/appwrite/appwrite
synced 2026-05-06 06:48:22 +00:00
chore: refactor finally clause
This commit is contained in:
parent
47ed708293
commit
ff1cabdbf7
2 changed files with 8 additions and 14 deletions
|
|
@ -1753,9 +1753,6 @@ App::post('/v1/functions/:functionId/executions')
|
|||
Console::error($th->getMessage());
|
||||
|
||||
if ($th instanceof AppwriteException) {
|
||||
if ($function->getAttribute('logging')) {
|
||||
Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution));
|
||||
}
|
||||
throw $th;
|
||||
}
|
||||
} finally {
|
||||
|
|
@ -1765,11 +1762,11 @@ App::post('/v1/functions/:functionId/executions')
|
|||
->addMetric(METRIC_EXECUTIONS_COMPUTE, (int)($execution->getAttribute('duration') * 1000)) // per project
|
||||
->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE), (int)($execution->getAttribute('duration') * 1000)) // per function
|
||||
;
|
||||
}
|
||||
|
||||
if ($function->getAttribute('logging')) {
|
||||
/** @var Document $execution */
|
||||
$execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution));
|
||||
if ($function->getAttribute('logging')) {
|
||||
/** @var Document $execution */
|
||||
$execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution));
|
||||
}
|
||||
}
|
||||
|
||||
$roles = Authorization::getRoles();
|
||||
|
|
|
|||
|
|
@ -300,9 +300,6 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo
|
|||
Console::error($th->getMessage());
|
||||
|
||||
if ($th instanceof AppwriteException) {
|
||||
if ($function->getAttribute('logging')) {
|
||||
Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution));
|
||||
}
|
||||
throw $th;
|
||||
}
|
||||
} finally {
|
||||
|
|
@ -312,11 +309,11 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo
|
|||
->addMetric(METRIC_EXECUTIONS_COMPUTE, (int)($execution->getAttribute('duration') * 1000)) // per project
|
||||
->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE), (int)($execution->getAttribute('duration') * 1000)) // per function
|
||||
;
|
||||
}
|
||||
|
||||
if ($function->getAttribute('logging')) {
|
||||
/** @var Document $execution */
|
||||
$execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution));
|
||||
if ($function->getAttribute('logging')) {
|
||||
/** @var Document $execution */
|
||||
$execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution));
|
||||
}
|
||||
}
|
||||
|
||||
$execution->setAttribute('logs', '');
|
||||
|
|
|
|||
Loading…
Reference in a new issue