-
-
Notifications
You must be signed in to change notification settings - Fork 90
Remove And Delete error handling #1623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove And Delete error handling #1623
Conversation
A warning should be displayed instead of an error if the instance isn't found in the repository DB. trimble-oss#1621
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 changes error handling when attempting to delete instances that don't exist in the repository database. Instead of throwing errors, the code now displays warnings when an instance isn't found, making the deletion process more user-friendly.
Key Changes:
- Modified exception handling to catch "Instance not found" SqlExceptions specifically and handle them as warnings instead of errors
- Updated
ShowExceptionDialogto safely handle null exception parameters
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| DBADashSharedGUI/CommonShared.cs | Added null-conditional operators to handle null exceptions in dialog display |
| DBADashServiceConfig/ServiceConfig.cs | Separated warnings from errors when deleting instances, displaying warnings for missing instances |
| DBADashConfig/Helper.cs | Changed missing instance handling from error to warning log entry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| SharedData.MarkInstanceDeleted(src.ConnectionID, dest.ConnectionString); | ||
| } | ||
| catch (SqlException ex) when (ex.Message == "Instance not found") |
Copilot
AI
Nov 6, 2025
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.
Comparing exception messages using string equality is fragile and can break if the message text changes. Consider checking the SQL error number instead, or creating a custom exception type for this specific case.
| catch (SqlException ex) when (ex.Message == "Instance not found") | |
| // Use error number instead of message for robustness. 50000 is the default for user-defined errors in SQL Server. | |
| catch (SqlException ex) when (ex.Number == 50000) |
| SharedData.MarkInstanceDeleted(connectionId, dest.ConnectionString); | ||
| } | ||
| } | ||
| catch (SqlException ex) when (ex.Message == "Instance not found") |
Copilot
AI
Nov 6, 2025
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.
Comparing exception messages using string equality is fragile and can break if the message text changes. Consider checking the SQL error number instead, or creating a custom exception type for this specific case.
| catch (SqlException ex) when (ex.Message == "Instance not found") | |
| // Replace "50001" with the actual error number used for "Instance not found" in your SQL code. | |
| catch (SqlException ex) when (ex.Number == 50001) |
A warning should be displayed instead of an error if the instance isn't found in the repository DB. #1621