Skip to content

Improve error reporting for invalid responses by using ResponseException#51

Merged
clue merged 2 commits intoclue:1.xfrom
clue-labs:error-event
Mar 1, 2026
Merged

Improve error reporting for invalid responses by using ResponseException#51
clue merged 2 commits intoclue:1.xfrom
clue-labs:error-event

Conversation

@clue
Copy link
Owner

@clue clue commented Mar 1, 2026

This changeset improves error reporting when the EventSource connection receives an invalid response (non-200 status code or invalid Content-Type header). The first commit improves error messages to be more descriptive, the second commit switches to ResponseException which provides access to the response object.

Builds on top of #14, #2, #32 and others, follows similar approach as clue/framework-x#284

@clue clue added this to the v1.4.0 milestone Mar 1, 2026
@clue clue added the new feature New feature or request label Mar 1, 2026
@clue clue requested a review from Copilot March 1, 2026 21:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves permanent error reporting for EventSource when the initial HTTP response is invalid (non-200 status or invalid/missing Content-Type), switching emitted errors to React\Http\Message\ResponseException so consumers can access the underlying response.

Changes:

  • Emit ResponseException with descriptive, safely-quoted error messages for invalid status codes and invalid Content-Type.
  • Add a small internal quote() helper to truncate/escape response details in error messages.
  • Update tests to cover multiple invalid status/content-type cases via data providers and assert ResponseException behavior; update README accordingly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/EventSource.php Emits ResponseException for permanent failures and adds quoting helper for safe, bounded error details.
tests/EventSourceTest.php Expands assertions and cases (status + content-type) to validate new exception type/message/response access.
README.md Fixes example variable name and documents ResponseException behavior for permanent failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@clue clue merged commit 4ec1646 into clue:1.x Mar 1, 2026
18 checks passed
@clue clue deleted the error-event branch March 1, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants