1
0
Fork 0
mirror of synced 2024-07-06 23:21:05 +12:00

Improve Executor client error handling

This commit is contained in:
Matej Baco 2022-11-23 09:41:48 +01:00
parent 948b14d139
commit 089a1b295c
2 changed files with 5 additions and 6 deletions

View file

@ -84,7 +84,7 @@ Server::setResource('execute', function () {
'functionId' => $functionId, 'functionId' => $functionId,
'deploymentId' => $deploymentId, 'deploymentId' => $deploymentId,
'trigger' => $trigger, 'trigger' => $trigger,
'status' => 'waiting', 'status' => 'processing',
'statusCode' => 0, 'statusCode' => 0,
'response' => '', 'response' => '',
'stderr' => '', 'stderr' => '',
@ -99,9 +99,6 @@ Server::setResource('execute', function () {
} }
} }
$execution->setAttribute('status', 'processing');
$execution = $dbForProject->updateDocument('executions', $executionId, $execution);
$vars = array_reduce($function->getAttribute('vars', []), function (array $carry, Document $var) { $vars = array_reduce($function->getAttribute('vars', []), function (array $carry, Document $var) {
$carry[$var->getAttribute('key')] = $var->getAttribute('value'); $carry[$var->getAttribute('key')] = $var->getAttribute('value');
return $carry; return $carry;

View file

@ -94,7 +94,8 @@ class Executor
$status = $response['headers']['status-code']; $status = $response['headers']['status-code'];
if ($status >= 400) { if ($status >= 400) {
throw new \Exception($response['body']['message'], $status); $message = \is_string($response['body'] ? $response['body'] : $response['body']['message']);
throw new \Exception($message, $status);
} }
return $response['body']; return $response['body'];
@ -146,7 +147,8 @@ class Executor
$status = $response['headers']['status-code']; $status = $response['headers']['status-code'];
if ($status >= 400) { if ($status >= 400) {
throw new \Exception($response['body']['message'], $status); $message = \is_string($response['body'] ? $response['body'] : $response['body']['message']);
throw new \Exception($message, $status);
} }
return $response['body']; return $response['body'];