getCasErrorCode converts the provided CAS error into the code that should be used to track the operation in metrics.
(err error)
| 25 | // getCasErrorCode converts the provided CAS error into the code that should be used to track the operation |
| 26 | // in metrics. |
| 27 | func getCasErrorCode(err error) string { |
| 28 | if err == nil { |
| 29 | return "200" |
| 30 | } |
| 31 | if resp, ok := httpgrpc.HTTPResponseFromError(err); ok { |
| 32 | return strconv.Itoa(int(resp.GetCode())) |
| 33 | } |
| 34 | |
| 35 | // If the error has been returned to abort the CAS operation, then we shouldn't |
| 36 | // consider it an error when tracking metrics. |
| 37 | if casErr, ok := err.(interface{ IsOperationAborted() bool }); ok && casErr.IsOperationAborted() { |
| 38 | return "200" |
| 39 | } |
| 40 | |
| 41 | return "500" |
| 42 | } |
| 43 | |
| 44 | type metrics struct { |
| 45 | c Client |
nothing calls this directly
no test coverage detected