This repository was archived by the owner on Jul 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 193
Changes to improve error handling and input validation #27
Merged
Conversation
This file contains hidden or 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
Refactored code to enhance error handling and user interaction: - Wrapped main logic in a try block for graceful exits on errors. - Moved variable initialization and template settings file reading inside the try block. - Added checks for the existence of TemplateSetting.json and handled file not found cases. - Encapsulated template settings parsing and validation within the try block. - Implemented user input validation for template number selection. - Streamlined authentication process for AD auth and PAT. - Encapsulated project creation process in a try block to handle exceptions. - Added prompt for creating another project after the current one. - Made minor formatting changes for better readability.
Updated GitRepository.json to replace repositories array with a parameters object, including gitSource URL, serviceEndpointId, and a flag for deleting the service endpoint post-import. Added settings.json to prefer the C# extension in .NET projects. Closes #21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request improves error handling and input validation in the ADOGenerator tool by adding try-catch blocks around key code sections and validating user input for organization name, personal access token, and project name.
- Added outer and nested try-catch blocks for catching exceptions.
- Enforced input validation with checks for empty organization names, PATs, and project names.
- Updated error messages and exit flows for a robust user experience.
Files not reviewed (4)
- src/ADOGenerator/Templates/AC-WVDGuidance/Extensions.json: Language not supported
- src/ADOGenerator/Templates/DL-Docker/Extensions.json: Language not supported
- src/ADOGenerator/Templates/DL-Selenium/Extensions.json: Language not supported
- src/ADOGenerator/Templates/Gen-MyShuttle/Extensions.json: Language not supported
Comments suppressed due to low confidence (1)
src/ADOGenerator/Program.cs:136
- [nitpick] Multiple catch blocks call Environment.Exit directly; consider centralizing the error handling and exit logic in a dedicated method to improve maintainability.
Environment.Exit(1);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves error handling and input validation in the ADO generator application and cleans up minor template content.
- Introduced try-catch blocks at multiple levels to catch and handle exceptions gracefully.
- Enhanced input validation for organization name, personal access token, and project name with detailed error messages.
- Removed redundant content from template JSON files.
Files not reviewed (4)
- src/ADOGenerator/Templates/AC-WVDGuidance/Extensions.json: Language not supported
- src/ADOGenerator/Templates/DL-Docker/Extensions.json: Language not supported
- src/ADOGenerator/Templates/DL-Selenium/Extensions.json: Language not supported
- src/ADOGenerator/Templates/Gen-MyShuttle/Extensions.json: Language not supported
Comments suppressed due to low confidence (3)
src/ADOGenerator/Program.cs:151
- [nitpick] Consider clarifying the error message to more explicitly state that the input should exclude the full URL prefix ("https://dev.azure.com/") and only include the organization name.
id.ErrorId().AddMessage("Please enter only the last part of the Azure DevOps URL (e.g., {ORGANIZATION_NAME} from https://dev.azure.com/{ORGANIZATION_NAME}).");
src/ADOGenerator/Program.cs:217
- [nitpick] Consider logging additional exception details such as the stack trace to better aid in debugging production issues.
Console.WriteLine($"An error occurred: {ex.Message}");
src/ADOGenerator/Program.cs:348
- [nitpick] Consider consolidating error handling messages with a centralized logging mechanism to maintain consistency and potentially improve resource cleanup before termination.
model.id.AddMessage("Exiting the application.");
Collaborator
Author
|
Closes #21 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request to
src/ADOGenerator/Program.csincludes several changes to improve error handling and input validation. Additionally, there are minor changes to theExtensions.jsonfiles in various template directories.Error handling improvements:
Input validation enhancements:
Template file changes:
Extensions.jsonfiles in various template directories. [1] [2] [3] [4]