MCPcopy Index your code
hub / github.com/coder/coder / retryMessage

Function retryMessage

coderd/x/chatd/chaterror/message.go:80–118  ·  view source on GitHub ↗

retryMessage produces a clean factual description suitable for display alongside the retry countdown UI. It omits HTTP status codes (surfaced separately in the payload) and remediation guidance (not actionable while auto-retrying).

(classified ClassifiedError)

Source from the content-addressed store, hash-verified

78// codes (surfaced separately in the payload) and remediation
79// guidance (not actionable while auto-retrying).
80func retryMessage(classified ClassifiedError) string {
81 if classified.Retryable && classified.Message != "" {
82 return classified.Message
83 }
84
85 subject := providerSubject(classified.Provider)
86 switch classified.Kind {
87 case codersdk.ChatErrorKindOverloaded:
88 return stringutil.Capitalize(fmt.Sprintf("%s is temporarily overloaded.", subject))
89 case codersdk.ChatErrorKindRateLimit:
90 return stringutil.Capitalize(fmt.Sprintf("%s is rate limiting requests.", subject))
91 case codersdk.ChatErrorKindTimeout:
92 return stringutil.Capitalize(fmt.Sprintf("%s is temporarily unavailable.", subject))
93 case codersdk.ChatErrorKindStartupTimeout:
94 return stringutil.Capitalize(fmt.Sprintf(
95 "%s did not start responding in time.", subject,
96 ))
97 case codersdk.ChatErrorKindAuth:
98 return fmt.Sprintf(
99 "Authentication with %s failed.", subject,
100 )
101 case codersdk.ChatErrorKindConfig:
102 return stringutil.Capitalize(fmt.Sprintf(
103 "%s rejected the model configuration.", subject,
104 ))
105 case codersdk.ChatErrorKindProviderDisabled:
106 displayName := providerDisplayName(classified.Provider)
107 return fmt.Sprintf(
108 "The %s provider has been disabled by an administrator.",
109 displayName,
110 )
111 case codersdk.ChatErrorKindMissingKey:
112 return "The API key for this conversation is no longer available."
113 default:
114 return stringutil.Capitalize(fmt.Sprintf(
115 "%s returned an unexpected error.", subject,
116 ))
117 }
118}
119
120func providerSubject(provider string) string {
121 if displayName := providerDisplayName(provider); displayName != "AI" && displayName != "" {

Callers 1

StreamRetryPayloadFunction · 0.85

Calls 2

providerSubjectFunction · 0.85
providerDisplayNameFunction · 0.85

Tested by

no test coverage detected