forked from tomkerkhove/promitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exit gracefully if a validation error occurs
I've tweaked the way that the startup process for Promitor works so that it runs the validation in the `Main()` method. This gives us the opportunity to exit gracefully if validation fails instead of throwing an exception. Also: - Added a new enum to track the possible exit statuses, and made sure that unhandled exceptions continue to use an exit code of `1`. - Updated the unhandled exception message to point people to raising an issue. - Altered the check to make sure the config folder is set so that it exits gracefully instead of ending up in the unhandled exception block. - Moved the logging about whether or not the configuration is valid from RuntimeValidator into the main method. It seemed more appropriate for the logging to be there since the main method now has logic for exiting if the config is invalid. Fixes tomkerkhove#1113
- Loading branch information
1 parent
8b3e730
commit eb1bb85
Showing
5 changed files
with
105 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Promitor.Agents.Scraper | ||
{ | ||
/// <summary> | ||
/// The different statuses that the agent scraper can exit with. | ||
/// </summary> | ||
public enum ExitStatus | ||
{ | ||
/// <summary> | ||
/// The application has run successfully. | ||
/// </summary> | ||
Success = 0, | ||
|
||
/// <summary> | ||
/// An unhandled exception was thrown during host startup. This probably | ||
/// indicates a bug in Promitor that should be reported. | ||
/// </summary> | ||
UnhandledException = 1, | ||
|
||
/// <summary> | ||
/// Validation failed, so Promitor can't start. | ||
/// </summary> | ||
ValidationFailed = 2, | ||
|
||
/// <summary> | ||
/// The configuration folder environment variable has not been set. | ||
/// </summary> | ||
ConfigurationFolderNotSpecified = 3 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters