mirror of
https://github.com/qicosmos/rest_rpc.git
synced 2026-08-29 08:34:47 +08:00
add duplicate registration test case
This commit is contained in:
+10
-20
@@ -50,16 +50,11 @@ public:
|
||||
template <bool is_pub = false, typename Function>
|
||||
void register_handler(std::string const &name, Function f, bool pub = false) {
|
||||
uint32_t key = MD5::MD5Hash32(name.data());
|
||||
try {
|
||||
if (key2func_name_.find(key) != key2func_name_.end()) {
|
||||
throw std::invalid_argument("duplicate registration key !");
|
||||
} else {
|
||||
key2func_name_.emplace(key, name);
|
||||
return register_nonmember_func<is_pub>(key, std::move(f));
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << e.what() << '\n';
|
||||
throw;
|
||||
if (key2func_name_.find(key) != key2func_name_.end()) {
|
||||
throw std::invalid_argument("duplicate registration key !");
|
||||
} else {
|
||||
key2func_name_.emplace(key, name);
|
||||
return register_nonmember_func<is_pub>(key, std::move(f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,16 +62,11 @@ public:
|
||||
void register_handler(std::string const &name, const Function &f,
|
||||
Self *self) {
|
||||
uint32_t key = MD5::MD5Hash32(name.data());
|
||||
try {
|
||||
if (key2func_name_.find(key) != key2func_name_.end()) {
|
||||
throw std::invalid_argument("duplicate registration key !");
|
||||
} else {
|
||||
key2func_name_.emplace(key, name);
|
||||
return register_member_func<is_pub>(key, f, self);
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << e.what() << '\n';
|
||||
throw;
|
||||
if (key2func_name_.find(key) != key2func_name_.end()) {
|
||||
throw std::invalid_argument("duplicate registration key !");
|
||||
} else {
|
||||
key2func_name_.emplace(key, name);
|
||||
return register_member_func<is_pub>(key, f, self);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user