Skip to content

Commit 42ec4d3

Browse files
GuiteOskarStark
authored andcommitted
[Platform][Gemini+OpenAI] Show error details to simplify localization of the cause
1 parent 7736543 commit 42ec4d3

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/platform/src/Bridge/Gemini/Gemini/ResultConverter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public function convert(RawResultInterface|RawHttpResult $result, array $options
5656
$data = $result->getData();
5757

5858
if (!isset($data['candidates'][0]['content']['parts'][0])) {
59+
if (isset($data['error'])) {
60+
throw new RuntimeException(\sprintf('Error "%s" - "%s": "%s".', $data['error']['code'], $data['error']['status'], $data['error']['message']));
61+
}
62+
5963
throw new RuntimeException('Response does not contain any content.');
6064
}
6165

src/platform/src/Bridge/OpenAi/Gpt/ResultConverter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ public function convert(RawResultInterface|RawHttpResult $result, array $options
7373
throw new ContentFilterException($data['error']['message']);
7474
}
7575

76+
if (isset($data['error'])) {
77+
throw new RuntimeException(\sprintf('Error "%s"-%s (%s): "%s".', $data['error']['code'], $data['error']['type'], $data['error']['param'], $data['error']['message']));
78+
}
79+
7680
if (!isset($data['choices'])) {
7781
throw new RuntimeException('Response does not contain choices.');
7882
}

0 commit comments

Comments
 (0)