MCPcopy Create free account
hub / github.com/google/go-cloud / errorState

Function errorState

runtimevar/awsparamstore/awsparamstore.go:196–220  ·  view source on GitHub ↗

errorState returns a new State with err, unless prevS also represents the same error, in which case it returns nil.

(err error, prevS driver.State)

Source from the content-addressed store, hash-verified

194// errorState returns a new State with err, unless prevS also represents
195// the same error, in which case it returns nil.
196func errorState(err error, prevS driver.State) driver.State {
197 // Map aws.RequestCanceled to the more standard context package errors.
198 if getErrorCode(err) == "CancelledError" {
199 msg := err.Error()
200 if strings.Contains(msg, "context deadline exceeded") {
201 err = context.DeadlineExceeded
202 } else {
203 err = context.Canceled
204 }
205 }
206 s := &state{err: err}
207 if prevS == nil {
208 return s
209 }
210 prev := prevS.(*state)
211 if prev.err == nil {
212 // New error.
213 return s
214 }
215 if equivalentError(err, prev.err) {
216 // Same error, return nil to indicate no change.
217 return nil
218 }
219 return s
220}
221
222// equivalentError returns true iff err1 and err2 represent an equivalent error;
223// i.e., we don't want to return it to the user as a different error.

Callers 1

WatchVariableMethod · 0.70

Calls 3

getErrorCodeFunction · 0.70
equivalentErrorFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected