fix: add error handling to ClaudeService streaming #54

Merged
Snider merged 1 commit from fix/stream-error-handling into main 2026-02-23 11:39:17 +00:00
Member

Summary

  • Wrap ClaudeService::stream() in try/catch to prevent silent failures
  • Yield a structured error event ['type' => 'error', 'message' => string] on exception
  • Log stream errors via Log::error() with context

Error Event Format

On stream failure, a single array event is yielded before the generator terminates:

['type' => 'error', 'message' => 'Description of the error']

Test Plan

  • Connection exception yields error event with type: error
  • Runtime exception yields error event with correct message
  • Error event has both type and message keys
  • Log::error is called with error context
  • Normal stream (no error) still yields text chunks correctly

Closes #26
Resolves ERR-001 in TODO.md

🤖 Generated with Claude Code

## Summary - Wrap `ClaudeService::stream()` in `try/catch` to prevent silent failures - Yield a structured error event `['type' => 'error', 'message' => string]` on exception - Log stream errors via `Log::error()` with context ## Error Event Format On stream failure, a single array event is yielded before the generator terminates: ```php ['type' => 'error', 'message' => 'Description of the error'] ``` ## Test Plan - [x] Connection exception yields error event with `type: error` - [x] Runtime exception yields error event with correct message - [x] Error event has both `type` and `message` keys - [x] `Log::error` is called with error context - [x] Normal stream (no error) still yields text chunks correctly Closes #26 Resolves ERR-001 in TODO.md 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Clotho added 1 commit 2026-02-23 11:05:03 +00:00
fix: add error handling to ClaudeService streaming (#26)
Some checks failed
CI / PHP 8.3 (pull_request) Failing after 1m53s
CI / PHP 8.4 (pull_request) Failing after 1m52s
77e4ae6bad
Wrap stream() in try/catch to prevent silent failures.
On exception, log the error and yield a structured error event:
  ['type' => 'error', 'message' => string]

Adds tests for connection errors, runtime exceptions, error event
format, and Log::error invocation. Closes ERR-001 in TODO.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Snider merged commit f528f94d68 into main 2026-02-23 11:39:17 +00:00
Snider deleted branch fix/stream-error-handling 2026-02-23 11:39:17 +00:00
Sign in to join this conversation.
No description provided.