Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Conversation

@akshay-online
Copy link
Collaborator

This pull request to src/ADOGenerator/Program.cs includes several changes to improve error handling and input validation. Additionally, there are minor changes to the Extensions.json files in various template directories.

Error handling improvements:

  • Added try-catch blocks around key sections of the code to handle exceptions and provide user-friendly error messages. [1] [2] [3] [4] [5]

Input validation enhancements:

  • Added checks to ensure that the organization name, personal access token, and project name are not empty and provide appropriate error messages if they are invalid.

Template file changes:

  • Removed unnecessary content from Extensions.json files in various template directories. [1] [2] [3] [4]

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
@akshay-online akshay-online requested a review from Copilot March 25, 2025 07:36
Copy link

Copilot AI left a 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);

@akshay-online akshay-online requested a review from Copilot March 25, 2025 07:46
Copy link

Copilot AI left a 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.");

@akshay-online
Copy link
Collaborator Author

Closes #21

@akshay-online akshay-online reopened this Mar 25, 2025
@akshay-online akshay-online merged commit 84f268e into main Mar 25, 2025
6 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants