mirror of
https://github.com/Metabolix/HackBGRT.git
synced 2025-12-06 17:15:42 -08:00
Add throwable for graceful exiting
This commit is contained in:
12
src/Setup.cs
12
src/Setup.cs
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user