| 5 | ) |
| 6 | |
| 7 | func NewStatusCodeError(status ResponseStatus) error { |
| 8 | switch status { |
| 9 | case StatusNoError: |
| 10 | return nil |
| 11 | case StatusKeyNotFound: |
| 12 | return errors.New("Key not found") |
| 13 | case StatusKeyExists: |
| 14 | return errors.New("Key exists") |
| 15 | case StatusValueTooLarge: |
| 16 | return errors.New("Value too large") |
| 17 | case StatusInvalidArguments: |
| 18 | return errors.New("Invalid arguments") |
| 19 | case StatusItemNotStored: |
| 20 | return errors.New("Item not stored") |
| 21 | case StatusIncrDecrOnNonNumericValue: |
| 22 | return errors.New("Incr/decr on non-numeric value") |
| 23 | case StatusVbucketBelongsToAnotherServer: |
| 24 | return errors.New("VBucket belongs to another server") |
| 25 | case StatusAuthenticationError: |
| 26 | return errors.New("Authentication error") |
| 27 | case StatusAuthenticationContinue: |
| 28 | return errors.New("Authentication continue") |
| 29 | case StatusUnknownCommand: |
| 30 | return errors.New("Unknown command") |
| 31 | case StatusOutOfMemory: |
| 32 | return errors.New("Server out of memory") |
| 33 | case StatusNotSupported: |
| 34 | return errors.New("Not supported") |
| 35 | case StatusInternalError: |
| 36 | return errors.New("Server internal error") |
| 37 | case StatusBusy: |
| 38 | return errors.New("Server busy") |
| 39 | case StatusTempFailure: |
| 40 | return errors.New("Temporary server failure") |
| 41 | default: |
| 42 | return errors.Newf("Invalid status: %d", int(status)) |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | // The genericResponse is an union of all response types. Response interfaces |
| 47 | // will cover the fact that there's only one implementation for everything. |