Skip to content

Commit 4fac972

Browse files
committed
Fix errors response
1 parent 79837e1 commit 4fac972

1 file changed

Lines changed: 7 additions & 30 deletions

File tree

ProcessMaker/Services/ScriptMicroserviceService.php

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Support\Facades\Http;
1111
use Illuminate\Support\Facades\Log;
1212
use ProcessMaker\Events\ScriptResponseEvent;
13+
use ProcessMaker\Exception\ScriptException;
1314
use ProcessMaker\Jobs\CompleteActivity;
1415
use ProcessMaker\Models\Process as Definitions;
1516
use ProcessMaker\Models\ProcessRequest;
@@ -280,43 +281,19 @@ private function formatPreviewResponse(array $response): array
280281
*/
281282
private function formatPreviewOutput(array $response): array
282283
{
283-
// For successful responses, return just the output array
284+
$output = $response;
284285
if (($response['status'] ?? '') === 'success') {
285-
return [
286-
'output' => $response['output'],
286+
$output = ['output' => $response['output']];
287+
} elseif ($response['status'] === 'error') {
288+
$output = [
289+
'exception' => $response['exception'] ?? ScriptException::class,
290+
'message' => $response['error'],
287291
];
288292
}
289293

290-
// For error responses, include error details
291-
$output = $response;
292-
293-
if (($response['status'] ?? '') === 'error') {
294-
$output['exception'] = $this->extractErrorDetails($response);
295-
$output['status'] = 'error';
296-
}
297-
298294
return $output;
299295
}
300296

301-
/**
302-
* Extract error details from response
303-
*
304-
* @param array $response
305-
* @return string
306-
*/
307-
private function extractErrorDetails(array $response): string
308-
{
309-
if (isset($response['output']['error'])) {
310-
return $response['output']['error'];
311-
}
312-
313-
if (isset($response['message'])) {
314-
return $response['message'];
315-
}
316-
317-
return 'Unknown error occurred';
318-
}
319-
320297
public function getInstanceUuid(): string
321298
{
322299
return Uuid::uuid5(

0 commit comments

Comments
 (0)