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

Function Code

gcerrors/errors.go:113–128  ·  view source on GitHub ↗

Code returns the ErrorCode of err if it, or some error it wraps, is an *Error. If err is context.Canceled or context.DeadlineExceeded, or wraps one of those errors, it returns the Canceled or DeadlineExceeded codes, respectively. If err is nil, it returns the special code OK. Otherwise, it returns U

(err error)

Source from the content-addressed store, hash-verified

111// If err is nil, it returns the special code OK.
112// Otherwise, it returns Unknown.
113func Code(err error) ErrorCode {
114 if err == nil {
115 return OK
116 }
117 var e *gcerr.Error
118 if errors.As(err, &e) {
119 return e.Code
120 }
121 if errors.Is(err, context.Canceled) {
122 return Canceled
123 }
124 if errors.Is(err, context.DeadlineExceeded) {
125 return DeadlineExceeded
126 }
127 return Unknown
128}

Callers 15

IsAccessibleMethod · 0.92
ExistsMethod · 0.92
wrapErrorFunction · 0.92
OpenMethod · 0.92
TestPreconditionsFunction · 0.92
testAttributesFunction · 0.92
testWriteFunction · 0.92
testCopyFunction · 0.92
testDeleteFunction · 0.92
testKeysFunction · 0.92

Calls 2

IsMethod · 0.80
AsMethod · 0.65

Tested by 15

TestPreconditionsFunction · 0.74
TestActionsDoFunction · 0.74
TestQueryValidFilterFunction · 0.74
TestInvalidQueryFunction · 0.74
TestQueryErrorsFunction · 0.74
TestNewDocumentFunction · 0.74
TestGetFieldFunction · 0.74
TestEncodeErrorsFunction · 0.74