You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When parsing two dots .. or two comas ,, the length formatter return NaN instead of an error.
I am parsing using the engineering length parser, in imperial.
I suggest that whenever we parse a NaN value, we convert the result to an error instead.
The text was updated successfully, but these errors were encountered:
By error, do you mean returning a ParseError?
I agree, for parseRatioFormat this is already what we do. We should streamline the behavior across the code.
We also still have the split between throwing a QuantityError and returning (not throwing) a ParseError.
The reasoning there is: QuanityError is for unexpected things, like misconfiguration or broken metadata while ParseError is for expected things (we expect parsing to fail frequently with unvalidated inputs). I think keeping it like that makes sense.
Im not sure which parsing got used here. Currently there are 2 parsing methods in Parser.ts, the async parseIntoQuantity and the sync parseQuantityString.
they both use Parser.parseQuantitySpecification to parse token and there was an error in there handling dots which I addressed in the pr. Now there shouldnt be any NaN value being returned.
The problem with returning an error on async parseIntoQuantity is that it returns a QuantityProps
it doesnt contain info on what the ParseError is. It does tell whether the returned Quantity is valid. (it did in the call stack calls getQuantityValueFromParseTokens but it didnt return the ParseQuantityResult returned right here
Maybe we can change the return type of the async method to match with the sync one. The sync one returns a QuantityParseResult
After the fix in the pr, the sync method returns ParseError.NoValueOrUnitFoundInString when parsing strings with only dots or comas.
The async method just returns an empty quantity right now, but it seemed more reasonable to me that the async method should return the same parse result as the sync one.
Im just not sure how this might affect things cause its changing the return type of a public api.
When parsing two dots
..
or two comas,,
the length formatter returnNaN
instead of an error.I am parsing using the engineering length parser, in imperial.
I suggest that whenever we parse a
NaN
value, we convert the result to an error instead.The text was updated successfully, but these errors were encountered: