string -> Fraction parsing now has error handling avoiding some problems

This commit is contained in:
N00MKRAD
2021-05-18 17:04:29 +02:00
parent 05a55fcbd5
commit 16b199f296
2 changed files with 56 additions and 30 deletions

View File

@@ -49,11 +49,29 @@ namespace Flowframes.Data
}
public Fraction(string text)
{
try
{
string[] numbers = text.Split('/');
Numerator = numbers[0].GetInt();
Denominator = numbers[1].GetInt();
}
catch
{
try
{
Numerator = text.GetFloat().RoundToInt();
Denominator = 1;
}
catch
{
Numerator = 0;
Denominator = 0;
}
}
Logger.Log($"Fraction from String: Fraction(\"{text}\") => {Numerator}/{Denominator}", true);
}
private static int getGCD(int a, int b)
{

View File

@@ -95,6 +95,8 @@ namespace Flowframes.Main
}
public static bool InputIsValid(string inDir, string outDir, Fraction fpsOut, float factor, I.OutMode outMode)
{
try
{
bool passes = true;
@@ -128,6 +130,12 @@ namespace Flowframes.Main
return passes;
}
catch(Exception e)
{
Logger.Log($"Failed to run InputIsValid: {e.Message}\n{e.StackTrace}", true);
return false;
}
}
public static bool CheckAiAvailable(AI ai)
{