void ConfigObject::SetHive(const ConfigHive::WeakPtr& hive)
{
if (m_Hive.lock())
- throw InvalidArgumentException();
+ throw InvalidArgumentException("Config object already has a parent hive.");
m_Hive = hive;
OnPropertyChanged += bind_weak(&ConfigObject::PropertyChangedHandler, shared_from_this());
dictionary = dynamic_pointer_cast<Dictionary>(data.GetObject());
if (dictionary == NULL)
- throw InvalidArgumentException();
+ throw InvalidArgumentException("Property is not a dictionary.");
*value = dictionary;
string method;
if (!request.GetMethod(&method))
- throw InvalidArgumentException();
+ throw InvalidArgumentException("Message is missing the 'method' property.");
for (list<Endpoint::Ptr>::iterator i = m_Endpoints.begin(); i != m_Endpoints.end(); i++)
{
int JsonRpcClient::DataAvailableHandler(const EventArgs& ea)
{
- Message message;
- bool message_read;
-
while (true) {
try {
- message_read = Netstring::ReadMessageFromFIFO(GetRecvQueue(), &message);
+ Message message;
+
+ if (Netstring::ReadMessageFromFIFO(GetRecvQueue(), &message)) {
+ NewMessageEventArgs nea;
+ nea.Source = shared_from_this();
+ nea.Message = message;
+ OnNewMessage(nea);
+ }
} catch (const Exception& ex) {
- cerr << "Exception while reading from JSON-RPC client: " << ex.GetMessage() << endl;
+ Application::Log("Exception while processing message from JSON-RPC client: " + ex.GetMessage());
Close();
return 1;
}
-
- if (!message_read)
- break;
-
- NewMessageEventArgs nea;
- nea.Source = shared_from_this();
- nea.Message = message;
- OnNewMessage(nea);
}
return 0;