diff --git a/src/backends/redis/command.cpp b/src/backends/redis/command.cpp index 0007aec..a2d6d37 100644 --- a/src/backends/redis/command.cpp +++ b/src/backends/redis/command.cpp @@ -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 diff --git a/src/backends/redis/command.hpp b/src/backends/redis/command.hpp index 4626e9b..4524f3d 100644 --- a/src/backends/redis/command.hpp +++ b/src/backends/redis/command.hpp @@ -31,6 +31,7 @@ #include #include #include +#include struct redisContext; @@ -88,6 +89,11 @@ namespace redis { LengthArray{ arg_to_bin_safe_length(string_ref(parCommand)), arg_to_bin_safe_length(std::forward(parArgs))... }.data() ); } + + class RedisError : public std::runtime_error { + public: + RedisError ( const char* parMessage, std::size_t parLength ); + }; } //namespace redis #endif