Added API error separation by their HTTP codes#440
Added API error separation by their HTTP codes#440LuckThemAll wants to merge 1 commit intoopenai-php:mainfrom
Conversation
| $contents = $response->getBody()->getContents(); | ||
|
|
||
| if (str_contains($response->getHeaderLine('Content-Type'), ContentType::TEXT_PLAIN->value)) { | ||
| return Response::from($contents, $response->getHeaders()); | ||
| } |
There was a problem hiding this comment.
The work in this PR looks good but I'm seeing intermittent requests failing due to OpenAI API flakeyness (#478). This block needs some of the precautions of throwIfJsonError() otherwise the string response data starts causing TypeError.
Status Code: 404
Content-Type: "text\/plain; charset=utf-8"
Body: "404 page not found\n"
|
Marking as draft due to test failures & conflicts. Sorry for delay. |
|
@iBotPeaches is this something you'd accept if I resubmit the PR? |
|
@bytestream - You like hitting me with all the Exception related ones :) - A bit torn on this one because this library is used for so many more services than just OpenAI and it seems to make some large assumptions on HTTP code and introduce a lot more exceptions. I think for me the improvements to make are:
Those are a bit easier in my head to accept. |
What:
Description:
Added separation of API errors by their HTTP codes. This enhancement improves error handling by categorizing errors based on their HTTP status codes, allowing for more precise error management and debugging.
Related:
#402