MCPcopy
hub / github.com/redis/go-redis / getErrorCategory

Function getErrorCategory

extra/redisotel-native/metrics.go:362–380  ·  view source on GitHub ↗

getErrorCategory returns the error category from an error. It checks for TLS, auth, network, and server errors.

(err error)

Source from the content-addressed store, hash-verified

360// getErrorCategory returns the error category from an error.
361// It checks for TLS, auth, network, and server errors.
362func getErrorCategory(err error) string {
363 if err == nil {
364 return ""
365 }
366
367 errStr := err.Error()
368
369 // For actual errors, also check error types
370 if isNetworkError(err) || isTimeoutError(err) {
371 return "network"
372 }
373
374 // Check for Redis server errors by prefix
375 if prefix := extractRedisErrorPrefix(err); prefix != "" {
376 return "server"
377 }
378
379 return getErrorCategoryFromString(errStr)
380}
381
382// getErrorCategoryFromString returns the error category from an error string or error type.
383// This is used both by getErrorCategory (for errors) and directly for error type strings.

Callers 3

Calls 5

isNetworkErrorFunction · 0.85
extractRedisErrorPrefixFunction · 0.85
isTimeoutErrorFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected