Skip to content

Commit f43dc67

Browse files
Aggregate exceptions in ParseSettingValueBoolean(object, string) by adding IList<Exception> parameter
1 parent ea0d1b6 commit f43dc67

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

Engine/Settings.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -302,21 +302,23 @@ private List<string> ParseSettingValueStringOrStrings(object value, string setti
302302
return strings;
303303
}
304304

305-
private bool ParseSettingValueBoolean(object value, string settingName)
305+
private bool? ParseSettingValueBoolean(object value, string settingName, IList<Exception> exceptions)
306306
{
307307
if (value == null)
308308
{
309-
throw new InvalidDataException(string.Format(
309+
exceptions.Add(new InvalidDataException(string.Format(
310310
Strings.SettingValueIsNull,
311-
settingName));
311+
settingName)));
312+
return null;
312313
}
313314

314315
if (!(value is bool))
315316
{
316-
throw new InvalidDataException(string.Format(
317+
exceptions.Add(new InvalidDataException(string.Format(
317318
Strings.SettingValueIsNotBooleanType,
318319
settingName,
319-
value));
320+
value)));
321+
return null;
320322
}
321323

322324
return (bool) value;
@@ -386,13 +388,23 @@ private void ParseSettingsHashtable(Hashtable settings)
386388
break;
387389

388390
case "includedefaultrules":
389-
// TODO Aggregate exceptions.
390-
this.includeDefaultRules = ParseSettingValueBoolean(setting.Value, settingName);
391+
bool? maybeIncludeDefaultRules = ParseSettingValueBoolean(setting.Value, settingName, exceptions);
392+
if (maybeIncludeDefaultRules is null)
393+
{
394+
continue;
395+
}
396+
397+
this.includeDefaultRules = (bool) maybeIncludeDefaultRules;
391398
break;
392399

393400
case "recursecustomrulepath":
394-
// TODO Aggregate exceptions.
395-
this.recurseCustomRulePath = ParseSettingValueBoolean(setting.Value, settingName);
401+
bool? maybeRecurseCustomRulePath = ParseSettingValueBoolean(setting.Value, settingName, exceptions);
402+
if (maybeRecurseCustomRulePath is null)
403+
{
404+
continue;
405+
}
406+
407+
this.recurseCustomRulePath = (bool) maybeRecurseCustomRulePath;
396408
break;
397409

398410
case "rules":

0 commit comments

Comments
 (0)