Fix #4295: Game crash if the syntax of users.json file is wong

JsonException was not being caught in NetworkUser::Load().
This commit is contained in:
Ted John 2016-08-16 21:24:03 +01:00
parent 3f9c5456d4
commit 560957824a
1 changed files with 16 additions and 8 deletions

View File

@ -18,6 +18,7 @@
#include <unordered_set>
#include "../core/Console.hpp"
#include "../core/Json.hpp"
#include "../core/Path.hpp"
#include "../core/String.hpp"
@ -94,6 +95,8 @@ void NetworkUserManager::Load()
{
DisposeUsers();
try
{
json_t * jsonUsers = Json::ReadFromFile(path);
size_t numUsers = json_array_size(jsonUsers);
for (size_t i = 0; i < numUsers; i++)
@ -107,6 +110,11 @@ void NetworkUserManager::Load()
}
json_decref(jsonUsers);
}
catch (Exception ex)
{
Console::Error::WriteLine("Failed to read %s as JSON. %s", path, ex.GetMsg());
}
}
}
void NetworkUserManager::Save()