Add throwable for graceful exiting

This commit is contained in:
Lauri Kenttä
2017-09-30 16:36:50 +03:00
parent 7ad4762a3d
commit e092c4768c

View File

@@ -14,6 +14,16 @@ public class Setup: SetupHelper {
}
}
/**
* A custom exception class for simply exiting the application.
*/
public class ExitSetup: Exception {
public readonly int Code;
public ExitSetup(int code) {
Code = code;
}
}
/**
* Find or mount or manually choose the EFI System Partition.
*/
@@ -309,6 +319,8 @@ public class Setup: SetupHelper {
throw new SetupException("Invalid choice!");
}
}
} catch (ExitSetup e) {
Environment.ExitCode = e.Code;
} catch (SetupException e) {
Console.WriteLine("Error: {0}", e.Message);
Environment.ExitCode = 1;