mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #12724 from appwrite/fix-build-error-classification
Fix build failure error classification
This commit is contained in:
4 files changed
+37
-8
No files matched your search
+1
-1
@@ -1194,7 +1194,7 @@ services:
|
||||
max-file: "5"
|
||||
max-size: 10m
|
||||
stop_signal: SIGINT
|
||||
image: openruntimes/executor:0.25.1
|
||||
image: openruntimes/executor:0.25.2
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- appwrite
|
||||
|
||||
@@ -17,6 +17,7 @@ use Appwrite\Usage\Context;
|
||||
use Appwrite\Utopia\Response\Model\Deployment;
|
||||
use Appwrite\Vcs\Comment;
|
||||
use Exception;
|
||||
use Executor\Exception as ExecutorException;
|
||||
use Executor\Exception\Timeout as ExecutorTimeout;
|
||||
use Executor\Executor;
|
||||
use Swoole\Coroutine as Co;
|
||||
@@ -757,6 +758,14 @@ class Builds extends Action
|
||||
$span?->set('build.runtime.error_type', $error::class);
|
||||
$span?->set('build.runtime.error_message', $error->getMessage());
|
||||
$err = new BuildException(type: AppwriteException::BUILD_TIMEOUT, previous: $error);
|
||||
} catch (ExecutorException $error) {
|
||||
$span?->set('build.runtime.error_type', $error::class);
|
||||
$span?->set('build.runtime.error_message', $error->getMessage());
|
||||
$span?->set('build.runtime.executor_error_type', $error->getType());
|
||||
|
||||
$err = $error->getType() === ExecutorException::BUILD_FAILED
|
||||
? new BuildException($error->getMessage(), previous: $error)
|
||||
: $error;
|
||||
} catch (\Throwable $error) {
|
||||
$span?->set('build.runtime.error_type', $error::class);
|
||||
$span?->set('build.runtime.error_message', $error->getMessage());
|
||||
|
||||
@@ -4,4 +4,20 @@ namespace Executor;
|
||||
|
||||
class Exception extends \Exception
|
||||
{
|
||||
public const string GENERAL_UNKNOWN = 'general_unknown';
|
||||
public const string BUILD_FAILED = 'build_failed';
|
||||
|
||||
public function __construct(
|
||||
string $message = '',
|
||||
int $code = 0,
|
||||
?\Throwable $previous = null,
|
||||
private readonly string $type = self::GENERAL_UNKNOWN,
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
}
|
||||
@@ -105,8 +105,9 @@ class Executor
|
||||
|
||||
$status = $response['headers']['status-code'];
|
||||
if ($status >= 400) {
|
||||
$message = \is_string($response['body']) ? $response['body'] : $response['body']['message'];
|
||||
throw new ExecutorException($message, $status);
|
||||
$message = \is_string($response['body']) ? $response['body'] : ($response['body']['message'] ?? '');
|
||||
$type = \is_array($response['body']) ? ($response['body']['type'] ?? ExecutorException::GENERAL_UNKNOWN) : ExecutorException::GENERAL_UNKNOWN;
|
||||
throw new ExecutorException($message, $status, type: $type);
|
||||
}
|
||||
|
||||
return $response['body'];
|
||||
@@ -165,7 +166,8 @@ class Executor
|
||||
}
|
||||
|
||||
if ($status >= 400) {
|
||||
throw new ExecutorException($message, $status);
|
||||
$type = \is_array($response['body']) ? ($response['body']['type'] ?? ExecutorException::GENERAL_UNKNOWN) : ExecutorException::GENERAL_UNKNOWN;
|
||||
throw new ExecutorException($message, $status, type: $type);
|
||||
}
|
||||
|
||||
return $response['body'];
|
||||
@@ -248,8 +250,9 @@ class Executor
|
||||
|
||||
$status = $response['headers']['status-code'];
|
||||
if ($status >= 400) {
|
||||
$message = \is_string($response['body']) ? $response['body'] : $response['body']['message'];
|
||||
throw new ExecutorException($message, $status);
|
||||
$message = \is_string($response['body']) ? $response['body'] : ($response['body']['message'] ?? '');
|
||||
$type = \is_array($response['body']) ? ($response['body']['type'] ?? ExecutorException::GENERAL_UNKNOWN) : ExecutorException::GENERAL_UNKNOWN;
|
||||
throw new ExecutorException($message, $status, type: $type);
|
||||
}
|
||||
|
||||
$headers = $response['body']['headers'] ?? [];
|
||||
@@ -282,8 +285,9 @@ class Executor
|
||||
|
||||
$status = $response['headers']['status-code'];
|
||||
if ($status >= 400) {
|
||||
$message = \is_string($response['body']) ? $response['body'] : $response['body']['message'];
|
||||
throw new ExecutorException($message, $status);
|
||||
$message = \is_string($response['body']) ? $response['body'] : ($response['body']['message'] ?? '');
|
||||
$type = \is_array($response['body']) ? ($response['body']['type'] ?? ExecutorException::GENERAL_UNKNOWN) : ExecutorException::GENERAL_UNKNOWN;
|
||||
throw new ExecutorException($message, $status, type: $type);
|
||||
}
|
||||
|
||||
return $response['body'];
|
||||
|
||||
Reference in new issue
Block a user