mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-02 14:04:22 +00:00
Don't throw if reply is of error type - just put it in Reply.
This commit is contained in:
parent
53a42fa7c0
commit
cdae333e1f
3 changed files with 17 additions and 13 deletions
|
@ -43,7 +43,7 @@ namespace redis {
|
||||||
PtrToReplyIterator(parReply->element + parReply->elements, &make_redis_reply_type)
|
PtrToReplyIterator(parReply->element + parReply->elements, &make_redis_reply_type)
|
||||||
);
|
);
|
||||||
case REDIS_REPLY_ERROR:
|
case REDIS_REPLY_ERROR:
|
||||||
throw RedisError(parReply->str, parReply->len);
|
return ErrorString(parReply->str, parReply->len);
|
||||||
default:
|
default:
|
||||||
return Reply();
|
return Reply();
|
||||||
};
|
};
|
||||||
|
@ -143,9 +143,4 @@ namespace redis {
|
||||||
auto Command::zscan (boost::string_ref parKey) -> zscan_range {
|
auto Command::zscan (boost::string_ref parKey) -> zscan_range {
|
||||||
return zscan_range(zscan_iterator(this, parKey, false), zscan_iterator(this, parKey, true));
|
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
|
} //namespace redis
|
||||||
|
|
|
@ -90,11 +90,6 @@ namespace redis {
|
||||||
LengthArray{ arg_to_bin_safe_length(string_ref(parCommand)), arg_to_bin_safe_length(std::forward<Args>(parArgs))... }.data()
|
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
|
} //namespace redis
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,17 +25,30 @@
|
||||||
namespace redis {
|
namespace redis {
|
||||||
struct Reply;
|
struct Reply;
|
||||||
|
|
||||||
|
class ErrorString {
|
||||||
|
public:
|
||||||
|
ErrorString ( const char* parCStr, std::size_t parLen ) :
|
||||||
|
m_msg(parCStr, parLen)
|
||||||
|
{ }
|
||||||
|
const std::string& message ( void ) const noexcept { return m_msg; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_msg;
|
||||||
|
};
|
||||||
|
|
||||||
namespace implem {
|
namespace implem {
|
||||||
using RedisVariantType = boost::variant<
|
using RedisVariantType = boost::variant<
|
||||||
long long,
|
long long,
|
||||||
std::string,
|
std::string,
|
||||||
std::vector<Reply>
|
std::vector<Reply>,
|
||||||
|
ErrorString
|
||||||
>;
|
>;
|
||||||
} //namespace implem
|
} //namespace implem
|
||||||
enum RedisVariantTypes {
|
enum RedisVariantTypes {
|
||||||
RedisVariantType_Integer = 0,
|
RedisVariantType_Integer = 0,
|
||||||
RedisVariantType_String,
|
RedisVariantType_String,
|
||||||
RedisVariantType_Array
|
RedisVariantType_Array,
|
||||||
|
RedisVariantType_Error
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Reply : implem::RedisVariantType {
|
struct Reply : implem::RedisVariantType {
|
||||||
|
@ -45,6 +58,7 @@ namespace redis {
|
||||||
Reply ( long long parVal ) : base_class(parVal) {}
|
Reply ( long long parVal ) : base_class(parVal) {}
|
||||||
Reply ( std::string&& parVal ) : base_class(std::move(parVal)) {}
|
Reply ( std::string&& parVal ) : base_class(std::move(parVal)) {}
|
||||||
Reply ( std::vector<Reply>&& parVal ) : base_class(std::move(parVal)) {}
|
Reply ( std::vector<Reply>&& parVal ) : base_class(std::move(parVal)) {}
|
||||||
|
Reply ( ErrorString&& parVal ) : base_class(std::move(parVal)) {}
|
||||||
~Reply ( void ) noexcept = default;
|
~Reply ( void ) noexcept = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue