1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-19 04:13:02 +00:00

Added converters/handling for values too big to fit decimal

This commit is contained in:
JKorf
2024-08-07 14:00:50 +02:00
parent 637070a7ae
commit 7fde8bf5da
4 changed files with 161 additions and 2 deletions
@@ -22,10 +22,26 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
if (string.IsNullOrEmpty(value) || string.Equals("null", value))
return null;
return decimal.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture);
try
{
return decimal.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture);
}
catch(OverflowException)
{
// Value doesn't fit decimal, default to max value
return decimal.MaxValue;
}
}
return reader.GetDecimal();
try
{
return reader.GetDecimal();
}
catch(FormatException)
{
// Format issue, assume value is too large
return decimal.MaxValue;
}
}
/// <inheritdoc />