Wrap json parsing in try/catch

This commit is contained in:
Pepe Rivera 2019-06-03 13:58:37 -07:00 committed by Matt Cooley
commit 10857b41d2

View file

@ -530,7 +530,22 @@ bool CurrencyDataLoader::TryParseStaticData(_In_ String^ rawJson, _Inout_ vector
staticData.resize(size_t{ data->Size });
for (unsigned int i = 0; i < data->Size; i++)
{
JsonObject^ obj = data->GetAt(i)->GetObject();
JsonObject ^ obj;
try
{
obj = data->GetAt(i)->GetObject();
}
catch (COMException ^ e)
{
if (e->HResult == E_ILLEGAL_METHOD_CALL)
{
continue;
}
else
{
throw;
}
}
for (size_t j = 0; j < values.size(); j++)
{
@ -568,7 +583,22 @@ bool CurrencyDataLoader::TryParseAllRatiosData(_In_ String^ rawJson, _Inout_ Cur
allRatios.clear();
for (unsigned int i = 0; i < data->Size; i++)
{
JsonObject^ obj = data->GetAt(i)->GetObject();
JsonObject ^ obj;
try
{
obj = data->GetAt(i)->GetObject();
}
catch (COMException^ e)
{
if (e->HResult == E_ILLEGAL_METHOD_CALL)
{
continue;
}
else
{
throw;
}
}
// Rt is ratio, An is target currency ISO code.
double relativeRatio = obj->GetNamedNumber(StringReference(RATIO_KEY));