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

Function terminalMessage

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

terminalMessage produces the user-facing error description shown when retries are exhausted. HTTP status codes are carried in the classified payload's StatusCode field and rendered as a separate footer chip by the UI, so they are intentionally omitted here to avoid duplicating the same information i

(classified ClassifiedError)

Source from the content-addressed store, hash-verified

14// footer chip by the UI, so they are intentionally omitted here to
15// avoid duplicating the same information in two places.
16func terminalMessage(classified ClassifiedError) string {
17 subject := providerSubject(classified.Provider)
18 switch classified.Kind {
19 case codersdk.ChatErrorKindOverloaded:
20 return stringutil.Capitalize(fmt.Sprintf("%s is temporarily overloaded.", subject))
21
22 case codersdk.ChatErrorKindRateLimit:
23 return stringutil.Capitalize(fmt.Sprintf("%s is rate limiting requests.", subject))
24
25 case codersdk.ChatErrorKindTimeout:
26 if !classified.Retryable && classified.StatusCode == 0 {
27 return "The request timed out before it completed."
28 }
29 return stringutil.Capitalize(fmt.Sprintf("%s is temporarily unavailable.", subject))
30
31 case codersdk.ChatErrorKindStartupTimeout:
32 return stringutil.Capitalize(fmt.Sprintf(
33 "%s did not start responding in time.", subject,
34 ))
35
36 case codersdk.ChatErrorKindUsageLimit:
37 return stringutil.Capitalize(fmt.Sprintf(
38 "The usage quota for %s has been exceeded."+
39 " Check the billing and quota settings for the provider account.",
40 subject,
41 ))
42
43 case codersdk.ChatErrorKindAuth:
44 return fmt.Sprintf(
45 "Authentication with %s failed."+
46 " Check the API key and permissions.",
47 subject,
48 )
49
50 case codersdk.ChatErrorKindMissingKey:
51 return "This conversation was started with an API key that is no longer available." +
52 " Send your message again to continue."
53
54 case codersdk.ChatErrorKindConfig:
55 return stringutil.Capitalize(fmt.Sprintf(
56 "%s rejected the model configuration."+
57 " Check the selected model and provider settings.",
58 subject,
59 ))
60
61 case codersdk.ChatErrorKindProviderDisabled:
62 displayName := providerDisplayName(classified.Provider)
63 return fmt.Sprintf(
64 "The %s provider has been disabled."+
65 " Contact your Coder administrator.",
66 displayName,
67 )
68 default:
69 if !classified.Retryable && classified.StatusCode == 0 {
70 return "The chat request failed unexpectedly."
71 }
72 return stringutil.Capitalize(fmt.Sprintf("%s returned an unexpected error.", subject))
73 }

Callers 1

normalizeClassificationFunction · 0.85

Calls 2

providerSubjectFunction · 0.85
providerDisplayNameFunction · 0.85

Tested by

no test coverage detected