errorMessage maps a stream error into a one-line TUI hint, same format across all profiles.
(e llm.Event)
| 63 | // errorMessage maps a stream error into a one-line TUI hint, same format across |
| 64 | // all profiles. |
| 65 | func (m Model) errorMessage(e llm.Event) string { |
| 66 | if e.Err == nil { |
| 67 | return "" |
| 68 | } |
| 69 | switch { |
| 70 | case errors.Is(e.Err, cloud.ErrBudgetExhausted): |
| 71 | return "⚠ hamrpass depleted · top up at codehamr.com" |
| 72 | case errors.Is(e.Err, cloud.ErrUnauthorized): |
| 73 | return "⚠ key rejected · check models." + m.cfg.Active + ".key in .codehamr/config.yaml" |
| 74 | case isUnreachable(e.Err): |
| 75 | return "⚠ unreachable: " + m.cfg.ActiveURL() + " · /models to switch profile" |
| 76 | default: |
| 77 | return "⚠ " + e.Err.Error() |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | func isUnreachable(err error) bool { |
| 82 | _, ok := errors.AsType[cloud.ErrUnreachable](err) |