Open lydell opened 1 year ago
I suspect the problem is because of this line:
We are accessing the value as a float because it allows for big numbers (I think) and do the check after if the number is inside of the correct range.
We could change that to use float32
but this would probably just delay the problem. We can try using a try ... with
.
As a note for my self, in the Thoth.Json.Core version of the library the exception will be different depending on the language so I need to think of a way to unify them.
Whenever I use
Decode.fromString
, I expect it to return eitherOk
orError
and never throw exceptions.However, if the JSON contains a really large number, a
System.InvalidCastException
exception is thrown.The various int decoders do have bounds checking, and that works to some extent. But if the number is too crazy large, even the bounds check don’t help.
If this is a problem with how Newtonsoft does things, maybe add a
try-with
in Thoth.Json.Net?