Skip to content

Commit

Permalink
return nil when overflow or format of a number are incorrect.
Browse files Browse the repository at this point in the history
  • Loading branch information
vddCore committed Nov 14, 2023
1 parent 99b2348 commit a458a39
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,19 @@ public static DynamicValue ConvertToNumber(this DynamicValue a)
{
return double.Parse(a.String!);
}
catch (FormatException fe)
catch (FormatException)
{
return DynamicValue.Nil;
}
catch (OverflowException)
{
return DynamicValue.Nil;
}
catch (Exception e)
{
throw new MalformedNumberException(
$"Attempt to convert '{a.String}' to a number.",
fe
$"Attempt to convert '{a.String}' to a Number.",
e
);
}
}
Expand Down

0 comments on commit a458a39

Please sign in to comment.