handle tokenizing invalid numeric string correctly

rather than throwing when an invalid numeric string is read, our tokenizer now returns false so that error recovery methods can be attempted.
This commit is contained in:
Eliot Jones
2020-02-21 11:16:31 +00:00
parent 8d415fd162
commit c6dc4d9eb8

View File

@@ -96,7 +96,11 @@
token = NumericToken.OneThousand;
return true;
default:
var value = decimal.Parse(str, NumberStyles.Any, CultureInfo.InvariantCulture);
if (!decimal.TryParse(str, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
{
return false;
}
token = new NumericToken(value);
return true;
}