Skip to content

Commit e4ea336

Browse files
Wout Gevaerttransistive
authored andcommitted
Uniformize errors in Http\HttpHelper
Although this is a bit error-prone when ill-formatted jolt is transmitted, nothing should go horribly wrong
1 parent a2c289a commit e4ea336

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Http/HttpHelper.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,16 @@ public static function getJoltBody(string $contents): stdClass
149149
$rtr->info = $value;
150150
break;
151151
case 'error':
152-
if (isset($rtr->error)) {
152+
if (isset($rtr->errors)) {
153153
throw new UnexpectedValueException('Jolt response with multiple error rows received');
154154
}
155-
$rtr->error = $value;
155+
$rtr->errors = [];
156+
foreach ($value->errors as $error) {
157+
$rtr->errors[] = (object) [
158+
'code' => self::splitJoltSingleton($error->code)[1],
159+
'message' => self::splitJoltSingleton($error->message)[1],
160+
];
161+
}
156162
break;
157163
default:
158164
throw new UnexpectedValueException('Jolt response with unknown key received: '.$key);

0 commit comments

Comments
 (0)