Skip to content

Commit

Permalink
Update RPOP error messages for clarity and consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Kripu77 committed Jan 19, 2025
1 parent 60fb58b commit 530590a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
8 changes: 4 additions & 4 deletions docs/src/content/docs/commands/RPOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RPOP key [count]
- If `count` is greater than the number of elements in the list, all elements are removed and returned.
- If `count` is less than 0, the following error is returned:
```bash
(error) ERR value is not an integer or out of range
(error) value is out of range, must be positive
```

4. **Empty List**:
Expand All @@ -66,7 +66,7 @@ RPOP key [count]

3. `Invalid Count`

- Error Message: `(error) ERR value is not an integer or out of range`
- Error Message: `(error) value is out of range, must be positive`
- Cause: Occurs if the count parameter is less than 0.

## Example Usage
Expand Down Expand Up @@ -115,14 +115,14 @@ Passing a negative value for count will result in an error:

```bash
RPOP mylist -1
(error) ERR value is not an integer or out of range
(error) value is out of range, must be positive
```

Passing a non integer value as the count paramater will result in an error:

```bash
RPOP mylist secondlist
(error) ERR value is not an integer or a float
(error) value is out of range, must be positive
```


Expand Down
4 changes: 2 additions & 2 deletions integration_tests/commands/http/deque_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ func TestRPOPCount(t *testing.T) {
float64(4),
[]interface{}{"v4", "v3"},
[]interface{}{"v2", "v1"},
"ERR value is not an integer or out of range",
"ERR value is not an integer or a float",
"value is out of range, must be positive",
"value is out of range, must be positive",
float64(0),
},
},
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/commands/websocket/deque_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,8 @@ func TestRPOPCount(t *testing.T) {
float64(4),
[]interface{}{"v4", "v3"},
[]interface{}{"v2", "v1"},
"ERR value is not an integer or out of range",
"ERR value is not an integer or a float",
"value is out of range, must be positive",
"value is out of range, must be positive",
float64(0),
},
cleanupKey: "k",
Expand Down
5 changes: 3 additions & 2 deletions internal/errors/migrated_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (

// Standard error variables for various DiceDB-related error conditions.
var (
ErrAuthFailed = errors.New("AUTH failed") // Indicates authentication failure.
ErrIntegerOutOfRange = errors.New("ERR value is not an integer or out of range") // Represents a value that is either not an integer or is out of allowed range.
ErrAuthFailed = errors.New("AUTH failed") // Indicates authentication failure.
ErrIntegerOutOfRange = errors.New("ERR value is not an integer or out of range")
ErrValueMustBePositive = errors.New("value is out of range, must be positive")
ErrInvalidNumberFormat = errors.New("ERR value is not an integer or a float") // Signals that a value provided is not in a valid integer or float format.
ErrValueOutOfRange = errors.New("ERR value is out of range") // Indicates that a value is beyond the permissible range.
ErrOverflow = errors.New("ERR increment or decrement would overflow") // Signifies that an increment or decrement operation would exceed the limits.
Expand Down
4 changes: 2 additions & 2 deletions internal/eval/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4037,11 +4037,11 @@ func testEvalRPOP(t *testing.T, store *dstore.Store) {
},
"non-integer count": {
input: []string{"k", "abc"},
migratedOutput: EvalResponse{Result: nil, Error: errors.New("ERR value is not an integer or a float")},
migratedOutput: EvalResponse{Result: nil, Error: errors.New("value is out of range, must be positive")},
},
"negative count": {
input: []string{"k", "-1"},
migratedOutput: EvalResponse{Result: nil, Error: errors.New("ERR value is not an integer or out of range")},
migratedOutput: EvalResponse{Result: nil, Error: errors.New("value is out of range, must be positive")},
},
"key with different type": {
setup: func() {
Expand Down
2 changes: 1 addition & 1 deletion internal/eval/store_eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -3210,7 +3210,7 @@ func popElements(args []string, store *dstore.Store, direction string) *EvalResp
if nos < 0 {
return &EvalResponse{
Result: nil,
Error: diceerrors.ErrIntegerOutOfRange,
Error: diceerrors.ErrValueMustBePositive,
}
}
popNumber = nos
Expand Down

0 comments on commit 530590a

Please sign in to comment.