thrift: verify in set_keyspace that the keyspace exists

The original code just assigns value to _ks_name which is a sstring
so the try { } catch { } clause only gave the wrong impression that
something is checked.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
This commit is contained in:
Paweł Dziepak
2015-06-02 10:39:16 +02:00
parent 83fb8a37b6
commit 73ee82031b

View File

@@ -111,12 +111,12 @@ public:
}
void set_keyspace(tcxx::function<void()> cob, tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, const std::string& keyspace) {
try {
if (!_db.local().has_keyspace(keyspace)) {
complete_with_exception<InvalidRequestException>(std::move(exn_cob),
"keyspace %s does not exist", keyspace);
} else {
_ks_name = keyspace;
cob();
} catch (std::out_of_range& e) {
return complete_with_exception<InvalidRequestException>(std::move(exn_cob),
"keyspace %s does not exist", keyspace);
}
}