mirror of
https://github.com/we-promise/sure.git
synced 2026-05-08 21:25:00 +00:00
* Improve chat LLM error messages * Fix chat visibility regression in tests * Harden chat error handling for review feedback * Fix rubocop private method indentation * Fix nil presentable_error_message, i18n strings, bare rescue - Guard `presentable_error_message` with `return nil if error.blank?` so chats with no error return nil instead of the fallback string; this prevents the API serialisers from emitting a spurious error message and stops the mobile polling guard from firing on every successful chat - Move all hardcoded user-facing error strings into config/locales/models/chat/en.yml and reference them via I18n.t() - Replace bare `rescue` in `error_message_for` with `rescue StandardError` to avoid swallowing system-level exceptions - Update tests to reference I18n keys instead of raw strings, and add tests for the nil-error case and the unrecognized-error fallback https://claude.ai/code/session_01YFMjEds5WVyKPL42xBqMCX --------- Co-authored-by: SureBot <sure-bot@we-promise.com> Co-authored-by: Claude <noreply@anthropic.com>
19 lines
490 B
Ruby
19 lines
490 B
Ruby
# frozen_string_literal: true
|
|
|
|
json.chats @chats do |chat|
|
|
json.id chat.id
|
|
json.title chat.title
|
|
json.last_message_at chat.messages.ordered.first&.created_at&.iso8601
|
|
json.message_count chat.messages.count
|
|
json.error chat.presentable_error_message
|
|
json.created_at chat.created_at.iso8601
|
|
json.updated_at chat.updated_at.iso8601
|
|
end
|
|
|
|
json.pagination do
|
|
json.page @pagy.page
|
|
json.per_page @pagy.vars[:items]
|
|
json.total_count @pagy.count
|
|
json.total_pages @pagy.pages
|
|
end
|