Client("Expected nil") runtime errors when not specifying return type
richardhenry opened this issue · comments
If I call the xadd command without a return type I get an Error::Client("Expected nil")
runtime error:
con.xadd(...).await?;
This is fixed by specifying a return type:
let _: String = con.xadd(...).await?;
It's pretty easy to make this mistake, and it doesn't get caught until runtime which isn't great. I'm assuming that this is also an issue with other commands. If the caller expects ()
, maybe this shouldn't be an error at all?
Hi @richardhenry,
I'm wondering how I could differentiate an expected nil
response from the Redis server from the caller's will to ignore the response.
Maybe it is a nonsense to expect an absolute nil
response. The only interesting use case is to expect an Option as a response, which may or may not be nil
.
Yeah, my instinct is that it's not that useful to expect a nil response, and the tradeoff (that it's easy to end up with an unintended runtime error because you forgot a return a type) isn't worth it. But maybe there's a way to accomplish both goals.