Fix crash caused by malformed preference files, fixes #110

This commit is contained in:
Simon Robertshaw 2012-08-14 18:14:06 +01:00
parent a7711668b7
commit fc1274f381

View File

@ -83,9 +83,9 @@ Client::Client():
configFile.seekg(0, std::ios::beg); configFile.seekg(0, std::ios::beg);
if(fsize) if(fsize)
{ {
json::Reader::Read(configDocument, configFile);
try try
{ {
json::Reader::Read(configDocument, configFile);
authUser.ID = ((json::Number)(configDocument["User"]["ID"])).Value(); authUser.ID = ((json::Number)(configDocument["User"]["ID"])).Value();
authUser.SessionID = ((json::String)(configDocument["User"]["SessionID"])).Value(); authUser.SessionID = ((json::String)(configDocument["User"]["SessionID"])).Value();
authUser.SessionKey = ((json::String)(configDocument["User"]["SessionKey"])).Value(); authUser.SessionKey = ((json::String)(configDocument["User"]["SessionKey"])).Value();
@ -102,7 +102,7 @@ Client::Client():
catch (json::Exception &e) catch (json::Exception &e)
{ {
authUser = User(0, ""); authUser = User(0, "");
std::cerr << "Error: Client [Read User data from pref] " << e.what() << std::endl; std::cerr << "Error: Could not read data from prefs: " << e.what() << std::endl;
} }
} }
configFile.close(); configFile.close();