Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error formatting and error tests #58

Merged
merged 2 commits into from
Oct 20, 2024
Merged

Error formatting and error tests #58

merged 2 commits into from
Oct 20, 2024

Conversation

gillchristian
Copy link
Collaborator

No description provided.

@@ -149,6 +149,7 @@ impl Frame {
Frame::Error(s) => {
let mut bytes = Vec::with_capacity(1 + s.len() + CRLF.len());
bytes.push(u8::from(DataType::SimpleError));
bytes.extend_from_slice("ERR ".as_bytes());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All errors have the prefix ERR

$ redis-cli
127.0.0.1:6379> SET incr_by_key_4 234293482390480948029348230948
OK
127.0.0.1:6379> INCRBY incr_by_key_4 10
(error) ERR value is not an integer or out of range
127.0.0.1:6379> foo
(error) ERR unknown command 'foo', with args beginning with:
127.0.0.1:6379> bar
(error) ERR unknown command 'bar', with args beginning with:
127.0.0.1:6379> set foo
(error) ERR wrong number of arguments for 'set' command

The create even removes the first work because it assumes the server is sending the error with that prefix.

Initially I did some string manipulation to get the tests to pass but then I realized I should just add the ERR prefix and now it works.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great work! I was also thinking in doing some string manipulation. Glad you found this.

@ndelvalle ndelvalle merged commit eac28f8 into master Oct 20, 2024
0 of 2 checks passed
@ndelvalle ndelvalle deleted the fix/err-formatting branch October 20, 2024 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants