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
Get on non-existent key returns wrong error #16
Comments
Hi @mercxry Can you include the code you're using to call |
My bad, without type casting it was I don't know if it would fit in your design choices, but would it be possible to return a |
Actually reading this a bit more I think I understand better what you're saying. I agree that the I'll look into this, this is good feedback. |
Perfect! Let me know if you need help implementing it, I started using the library recently but I already prefer it over the other Redis libraries. Thanks for the awesome work :) |
Thanks for the kind words @mercxry, I hope this library helps. Just as a heads up, there's one or two type conversion implementations that might be somewhat controversial. As it stands right now trying to cast a That being said, I'm going to make these use cases return a That kind of thing also smells a lot like JavaScript and I'd like to avoid that as much as possible. |
I just shipped some changes in 4.2.3 that I think should help here. Let me know if this matches your use case and if so I'll close this out. Thanks for the good feedback @mercxry, getting a sense of real use cases like this is really helpful. |
Awesome! I just tried the new version and the error kind shows up as It should say something related to the |
Yeah I should have mentioned that in the last comment. I wanted to scope this change to just the error type variant since I'm in the middle of a major release (v5) that makes some drastic changes to errors and return values (RESP3 has value attributes, which are a big change to everything). I'll include your feedback here re: error messages in the changes in that release, but for now I'm hoping to limit changes on the 4.x branch to be as small as possible. |
Just so I don't forget I'm going to leave this open with a feature request tag as well. |
Just a heads up @mercxry - I've been doing some more thinking on this and I think I'm going to keep the current behavior from 4.x. This will keep the The type conversion logic is used in several places (such as the There's also some cases (such as HGET) where "key" is the wrong term and "field" may be more precise, but I'd rather not try to enumerate all of those cases. Since the error kind variant is still there callers can still match against something to check for the I might come back to this in a later version, but for now I think I'm going to keep the current message and error kind variants. |
Hello, when I try to get a non-existent key I receive this error:
Redis Error - kind: Parse, details: Cannot convert to number.
, but I believe this is the wrong type of error for the triggered action.What I would expect
Since the Redis CLI returns
nil
maybe the library should just return anOption::None
, or a different kind of RedisError likeNotFound
.Personally I think both solutions are right and in an ideal world there should be an option for both behaviors, but for my use case a different kind of error it's preferred since I want to do a specific action on specific errors and the error propagation operator (
?
) would help me achieve this more simply and in a cleaner way.The text was updated successfully, but these errors were encountered: