MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / enrichClientError

Function enrichClientError

cli/cmd/install.go:137–161  ·  view source on GitHub ↗

enrichClientError tries to add Hint messages to errors from managed client. It will also do an inferred-registry check on the failed client (which is one more than the last one on the list) and add the registry hint if needed.

(clientsList managedplugin.Clients, inferredList []bool, err error)

Source from the content-addressed store, hash-verified

135// enrichClientError tries to add Hint messages to errors from managed client.
136// It will also do an inferred-registry check on the failed client (which is one more than the last one on the list) and add the registry hint if needed.
137func enrichClientError(clientsList managedplugin.Clients, inferredList []bool, err error) error {
138 if err == nil {
139 return nil
140 }
141 if errors.Is(err, managedplugin.ErrLoginRequired) {
142 return fmt.Errorf("%w. Hint: You must be logged in via `cloudquery login` or you must use a valid API Key which can be generated at `cloud.cloudquery.io`", err)
143 }
144 if errors.Is(err, managedplugin.ErrTeamRequired) {
145 return fmt.Errorf("%w. Hint: use `cloudquery switch` to set a team", err)
146 }
147
148 if !strings.Contains(strings.ToLower(err.Error()), "not found") {
149 return err
150 }
151 l := len(clientsList)
152 il := len(inferredList)
153 if l > il {
154 return err // shouldn't happen
155 }
156 if !inferredList[l] {
157 return err
158 }
159
160 return fmt.Errorf("%w. Hint: make sure to use the latest plugin version from www.cloudquery.io/hub or to keep using an outdated version add `registry: github` to your configuration", err)
161}

Callers 6

testConnectionFunction · 0.85
syncFunction · 0.85
installPluginFunction · 0.85
migrateFunction · 0.85
tablesFunction · 0.85
validateConfigFunction · 0.85

Calls 2

ErrorfMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected