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); } }