Wrap json parsing in try/catch (#534)
This commit is contained in:
parent
2b17f82652
commit
6e3fe90eb5
@ -502,7 +502,22 @@ bool CurrencyDataLoader::TryParseStaticData(_In_ String ^ rawJson, _Inout_ vecto
|
|||||||
staticData.resize(size_t{ data->Size });
|
staticData.resize(size_t{ data->Size });
|
||||||
for (unsigned int i = 0; i < data->Size; i++)
|
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++)
|
for (size_t j = 0; j < values.size(); j++)
|
||||||
{
|
{
|
||||||
@ -531,7 +546,22 @@ bool CurrencyDataLoader::TryParseAllRatiosData(_In_ String ^ rawJson, _Inout_ Cu
|
|||||||
allRatios.clear();
|
allRatios.clear();
|
||||||
for (unsigned int i = 0; i < data->Size; i++)
|
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.
|
// Rt is ratio, An is target currency ISO code.
|
||||||
double relativeRatio = obj->GetNamedNumber(StringReference(RATIO_KEY));
|
double relativeRatio = obj->GetNamedNumber(StringReference(RATIO_KEY));
|
||||||
|
Loading…
Reference in New Issue
Block a user