You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(handlers): return Result and remove runtime panic paths (#605)
Handlers now return `Result<(), AppError>`; the dispatcher endpoint
collects the outcome and logs any error once at the boundary, swallowing
it so a single bad update can't tear down the dispatcher (§1).
Panic sites removed:
- chat_gpt_handler: `msg.text().expect(...)` (x2) -> `let Some(..) else`.
- url_summary_handler: `get_content_call(..).unwrap()` and
`html2text::from_read(..).unwrap()` -> `?` (HTTP via AppError::Http,
HTML parse via AppError::BadInput). `get_content_call` now returns
`Result<_, AppError>` instead of `Box<dyn Error>`.
- rust_mention_handler: `DateTime::from_timestamp(..).unwrap()` ->
`let Some(..) else { warn!; return Ok(()) }`.
- gpt_service: `gpt_call` returns `Result<_, AppError>` instead of
`Box<dyn Error>`; `choices[0]` index replaced with `.into_iter().next()`
+ fallback so an empty choices array can't panic.
- chat_repository: `FromRedisValue` for ChatMessage/BotProfile now maps a
serde failure to a `RedisError` instead of `.expect()`, so a corrupted
Redis payload returns an error rather than crashing.
The `.map_err(error!).ok()` best-effort swallows and the RUST_CHAT
constant are addressed in the next iteration. No happy-path behavior
change. Local gate green (fmt, clippy -D warnings, unit tests, all
integration tests compile).
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments