Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added API error separation by their HTTP codes #440

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LuckThemAll
Copy link

@LuckThemAll LuckThemAll commented Jun 30, 2024

What:

  • Bug Fix
  • New Feature

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

Comment on lines 62 to 66
$contents = $response->getBody()->getContents();

if (str_contains($response->getHeaderLine('Content-Type'), ContentType::TEXT_PLAIN->value)) {
return Response::from($contents, $response->getHeaders());
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants