From 73ee82031ba771be905a6fafe19db3c4e8f96038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Dziepak?= Date: Tue, 2 Jun 2015 10:39:16 +0200 Subject: [PATCH] thrift: verify in set_keyspace that the keyspace exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- thrift/handler.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/thrift/handler.cc b/thrift/handler.cc index ffca81ffa2..52a0296859 100644 --- a/thrift/handler.cc +++ b/thrift/handler.cc @@ -111,12 +111,12 @@ public: } void set_keyspace(tcxx::function cob, tcxx::function exn_cob, const std::string& keyspace) { - try { + if (!_db.local().has_keyspace(keyspace)) { + complete_with_exception(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(std::move(exn_cob), - "keyspace %s does not exist", keyspace); } }