Improve Executor client error handling
This commit is contained in:
parent
948b14d139
commit
089a1b295c
2 changed files with 5 additions and 6 deletions
|
@ -84,7 +84,7 @@ Server::setResource('execute', function () {
|
|||
'functionId' => $functionId,
|
||||
'deploymentId' => $deploymentId,
|
||||
'trigger' => $trigger,
|
||||
'status' => 'waiting',
|
||||
'status' => 'processing',
|
||||
'statusCode' => 0,
|
||||
'response' => '',
|
||||
'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) {
|
||||
$carry[$var->getAttribute('key')] = $var->getAttribute('value');
|
||||
return $carry;
|
||||
|
|
|
@ -94,7 +94,8 @@ class Executor
|
|||
|
||||
$status = $response['headers']['status-code'];
|
||||
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'];
|
||||
|
@ -146,7 +147,8 @@ class Executor
|
|||
|
||||
$status = $response['headers']['status-code'];
|
||||
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'];
|
||||
|
|
Loading…
Reference in a new issue