1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00

fix(builds): use standard Exception

This commit is contained in:
Steven Nguyen 2024-03-10 23:13:55 +01:00
parent 8e348dbd92
commit b7be370a53
No known key found for this signature in database

View file

@ -73,7 +73,7 @@ class Builds extends Action
$payload = $message->getPayload() ?? [];
if (empty($payload)) {
throw new Exception('Missing payload');
throw new \Exception('Missing payload');
}
$type = $payload['type'] ?? '';
@ -124,7 +124,7 @@ class Builds extends Action
$function = $dbForProject->getDocument('functions', $functionId);
if ($function->isEmpty()) {
throw new Exception('Function not found', 404);
throw new \Exception('Function not found', 404);
}
$deploymentId = $deployment->getId();
@ -132,11 +132,11 @@ class Builds extends Action
$deployment = $dbForProject->getDocument('deployments', $deploymentId);
if ($deployment->isEmpty()) {
throw new Exception('Deployment not found', 404);
throw new \Exception('Deployment not found', 404);
}
if (empty($deployment->getAttribute('entrypoint', ''))) {
throw new Exception('Entrypoint for your Appwrite Function is missing. Please specify it when making deployment or update the entrypoint under your function\'s "Settings" > "Configuration" > "Entrypoint".', 500);
throw new \Exception('Entrypoint for your Appwrite Function is missing. Please specify it when making deployment or update the entrypoint under your function\'s "Settings" > "Configuration" > "Entrypoint".', 500);
}
$version = $function->getAttribute('version', 'v2');
@ -144,7 +144,7 @@ class Builds extends Action
$key = $function->getAttribute('runtime');
$runtime = $runtimes[$key] ?? null;
if (\is_null($runtime)) {
throw new Exception('Runtime "' . $function->getAttribute('runtime', '') . '" is not supported');
throw new \Exception('Runtime "' . $function->getAttribute('runtime', '') . '" is not supported');
}
// Realtime preparation
@ -306,7 +306,7 @@ class Builds extends Action
$directorySize = $localDevice->getDirectorySize($tmpDirectory);
$functionsSizeLimit = (int) App::getEnv('_APP_FUNCTIONS_SIZE_LIMIT', '30000000');
if ($directorySize > $functionsSizeLimit) {
throw new Exception('Repository directory size should be less than ' . number_format($functionsSizeLimit / 1048576, 2) . ' MBs.');
throw new \Exception('Repository directory size should be less than ' . number_format($functionsSizeLimit / 1048576, 2) . ' MBs.');
}
Console::execute('tar --exclude code.tar.gz -czf ' . $tmpPathFile . ' -C /tmp/builds/' . \escapeshellcmd($buildId) . '/code' . (empty($rootDirectory) ? '' : '/' . $rootDirectory) . ' .', '', $stdout, $stderr);
@ -431,7 +431,7 @@ class Builds extends Action
$build = $dbForProject->getDocument('builds', $build->getId());
if ($build->isEmpty()) {
throw new Exception('Build not found', 404);
throw new \Exception('Build not found', 404);
}
$build = $build->setAttribute('logs', $build->getAttribute('logs', '') . $logs);