MCPcopy Index your code
hub / github.com/codehamr/codehamr / errorMessage

Method errorMessage

internal/tui/commands.go:65–79  ·  view source on GitHub ↗

errorMessage maps a stream error into a one-line TUI hint, same format across all profiles.

(e llm.Event)

Source from the content-addressed store, hash-verified

63// errorMessage maps a stream error into a one-line TUI hint, same format across
64// all profiles.
65func (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
81func isUnreachable(err error) bool {
82 _, ok := errors.AsType[cloud.ErrUnreachable](err)

Callers 4

applyErrorMethod · 0.95

Calls 3

isUnreachableFunction · 0.85
ActiveURLMethod · 0.80
ErrorMethod · 0.80

Tested by 3