mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-02-16 11:35:49 +00:00
Throw if Redis reply contains any error messages.
This commit is contained in:
parent
93e328d77f
commit
9a69b8de10
2 changed files with 13 additions and 0 deletions
|
@ -42,6 +42,8 @@ namespace redis {
|
|||
PtrToReplyIterator(parReply->element, &make_redis_reply_type),
|
||||
PtrToReplyIterator(parReply->element + parReply->elements, &make_redis_reply_type)
|
||||
);
|
||||
case REDIS_REPLY_ERROR:
|
||||
throw RedisError(parReply->str, parReply->len);
|
||||
default:
|
||||
return Reply();
|
||||
};
|
||||
|
@ -141,4 +143,9 @@ namespace redis {
|
|||
auto Command::zscan (boost::string_ref parKey) -> zscan_range {
|
||||
return zscan_range(zscan_iterator(this, parKey, false), zscan_iterator(this, parKey, true));
|
||||
}
|
||||
|
||||
RedisError::RedisError (const char* parMessage, std::size_t parLength) :
|
||||
std::runtime_error(std::string(parMessage, parLength))
|
||||
{
|
||||
}
|
||||
} //namespace redis
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <utility>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/utility/string_ref.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
struct redisContext;
|
||||
|
||||
|
@ -88,6 +89,11 @@ namespace redis {
|
|||
LengthArray{ arg_to_bin_safe_length(string_ref(parCommand)), arg_to_bin_safe_length(std::forward<Args>(parArgs))... }.data()
|
||||
);
|
||||
}
|
||||
|
||||
class RedisError : public std::runtime_error {
|
||||
public:
|
||||
RedisError ( const char* parMessage, std::size_t parLength );
|
||||
};
|
||||
} //namespace redis
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue