From: Aki Tuomi Date: Tue, 15 Jul 2014 18:20:44 +0000 (+0300) Subject: Fix exception handling and use "" for NULL X-Git-Tag: auth-3.4.0-rc1~79^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9305f5fd0b90a1db0bf5b8404193154d7a3f0f5a;p=thirdparty%2Fpdns.git Fix exception handling and use "" for NULL --- diff --git a/modules/remotebackend/pipeconnector.cc b/modules/remotebackend/pipeconnector.cc index 33c58897ba..140132a201 100644 --- a/modules/remotebackend/pipeconnector.cc +++ b/modules/remotebackend/pipeconnector.cc @@ -5,7 +5,7 @@ PipeConnector::PipeConnector(std::map options) { if (options.count("command") == 0) { L<command = options.find("command")->second; this->options = options; diff --git a/modules/remotebackend/remotebackend.cc b/modules/remotebackend/remotebackend.cc index b494ca4011..2e40846359 100644 --- a/modules/remotebackend/remotebackend.cc +++ b/modules/remotebackend/remotebackend.cc @@ -933,7 +933,7 @@ bool RemoteBackend::getBool(rapidjson::Value &value) { if (boost::iequals(tmp, "0") || boost::iequals(tmp, "false")) return false; } std::cerr << value.GetType() << endl; - throw new PDNSException("Cannot convert rapidjson value into boolean"); + throw PDNSException("Cannot convert rapidjson value into boolean"); } bool Connector::getBool(rapidjson::Value &value) { @@ -969,7 +969,7 @@ int RemoteBackend::getInt(rapidjson::Value &value) { std::string tmp = value.GetString(); return boost::lexical_cast(tmp); } - throw new PDNSException("Cannot convert rapidjson value into integer"); + throw PDNSException("Cannot convert rapidjson value into integer"); } unsigned int RemoteBackend::getUInt(rapidjson::Value &value) { @@ -981,7 +981,7 @@ unsigned int RemoteBackend::getUInt(rapidjson::Value &value) { std::string tmp = value.GetString(); return boost::lexical_cast(tmp); } - throw new PDNSException("Cannot convert rapidjson value into integer"); + throw PDNSException("Cannot convert rapidjson value into integer"); } int64_t RemoteBackend::getInt64(rapidjson::Value &value) { @@ -993,16 +993,17 @@ int64_t RemoteBackend::getInt64(rapidjson::Value &value) { std::string tmp = value.GetString(); return boost::lexical_cast(tmp); } - throw new PDNSException("Cannot convert rapidjson value into integer"); + throw PDNSException("Cannot convert rapidjson value into integer"); } std::string RemoteBackend::getString(rapidjson::Value &value) { + if (value.IsNull()) return ""; if (value.IsString()) return value.GetString(); if (value.IsBool()) return (value.GetBool() ? "true" : "false"); if (value.IsInt64()) return boost::lexical_cast(value.GetInt64()); if (value.IsInt()) return boost::lexical_cast(value.GetInt()); if (value.IsDouble()) return boost::lexical_cast(value.GetDouble()); - throw new PDNSException("Cannot convert rapidjson value into std::string"); + throw PDNSException("Cannot convert rapidjson value into std::string"); } double RemoteBackend::getDouble(rapidjson::Value &value) { @@ -1014,7 +1015,7 @@ double RemoteBackend::getDouble(rapidjson::Value &value) { std::string tmp = value.GetString(); return boost::lexical_cast(tmp); } - throw new PDNSException("Cannot convert rapidjson value into double"); + throw PDNSException("Cannot convert rapidjson value into double"); } DNSBackend *RemoteBackend::maker() diff --git a/modules/remotebackend/unixconnector.cc b/modules/remotebackend/unixconnector.cc index 1b68353703..f744462b23 100644 --- a/modules/remotebackend/unixconnector.cc +++ b/modules/remotebackend/unixconnector.cc @@ -10,7 +10,7 @@ UnixsocketConnector::UnixsocketConnector(std::map options) { if (options.count("path") == 0) { L<timeout = 2000; if (options.find("timeout") != options.end()) { diff --git a/modules/remotebackend/zmqconnector.cc b/modules/remotebackend/zmqconnector.cc index 3e96589ab2..5f863d2e8c 100644 --- a/modules/remotebackend/zmqconnector.cc +++ b/modules/remotebackend/zmqconnector.cc @@ -16,7 +16,7 @@ ZeroMQConnector::ZeroMQConnector(std::map options) : d_ // lookup timeout, target and stuff if (options.count("endpoint") == 0) { L<d_endpoint = options.find("endpoint")->second; this->d_options = options; @@ -74,7 +74,7 @@ int ZeroMQConnector::send_message(const rapidjson::Document &input) { } } catch (std::exception &ex) { L<d_endpoint << ": " << ex.what(); - throw new PDNSException(ex.what()); + throw PDNSException(ex.what()); } return 0; @@ -122,7 +122,7 @@ int ZeroMQConnector::recv_message(rapidjson::Document &output) { } } catch (std::exception &ex) { L<d_endpoint << ": " << ex.what(); - throw new PDNSException(ex.what()); + throw PDNSException(ex.what()); } return rv;