mirror of
https://github.com/Microsoft/calculator.git
synced 2025-07-08 14:10:46 -07:00
Wrap json parsing in try/catch (#534)
This commit is contained in:
parent
2b17f82652
commit
6e3fe90eb5
1 changed files with 32 additions and 2 deletions
|
@ -502,7 +502,22 @@ bool CurrencyDataLoader::TryParseStaticData(_In_ String ^ rawJson, _Inout_ vecto
|
|||
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++)
|
||||
{
|
||||
|
@ -531,7 +546,22 @@ bool CurrencyDataLoader::TryParseAllRatiosData(_In_ String ^ rawJson, _Inout_ Cu
|
|||
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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue