Improve Executor client error handling
This commit is contained in:
parent
948b14d139
commit
089a1b295c
|
@ -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;
|
||||||
|
|
|
@ -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'];
|
||||||
|
|
Loading…
Reference in a new issue