fix: Use specific exception types in ArmClientExtensions#1689
Conversation
Replace generic Exception throws with specific, descriptive exceptions: - AzureResourceNotFoundException: Thrown when a resource cannot be found in the resource group. Inherits from InvalidOperationException and includes the ResourceIdentifier for debugging. - UnsupportedAzureScopeException: Thrown when an unsupported scope type is encountered. Inherits from NotSupportedException and includes the Scope object for debugging. Added XML documentation for GetResourceIdentifierAsync explaining when each exception is thrown. Note: Issue #1574 (SuccessHttpHandler) was already fixed in commit 828c5b5 which removed the SuccessHttpHandler class entirely. Fixes #1578 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
SummaryReplaces generic exceptions with custom typed exceptions for Azure resource operations. Critical IssuesNone found ✅ SuggestionsException Constructor ConsistencyBoth new exception classes follow good practices with proper constructors accepting innerException. However, consider if serialization support is needed (though unlikely for ModularPipelines use case). Error Message QualityIn UnsupportedAzureScopeException:20, the error message includes both the type name AND the scope value. Since AzureScope is a record, the ToString() output might be redundant with the type name. Consider if this provides useful information or just noise. Example output would be: If the scope value is useful for debugging, this is fine. If not, you could simplify to just the type name. XML Documentation CompletenessThe XML documentation is well-written. The exceptions are properly marked with tags in the extension method's XML doc, which is excellent for API consumers. Previous Review StatusCannot access previous comments due to GitHub token scope limitations. Verdict✅ APPROVE - No critical issues The PR improves exception handling by replacing generic exceptions with strongly-typed, semantically meaningful exceptions. This makes it easier for consumers to catch and handle specific error scenarios. The implementation follows standard exception patterns with proper inheritance (InvalidOperationException for "not found", NotSupportedException for "unsupported scope") and includes well-documented constructors. |
Summary
AzureResourceNotFoundException(inheritsInvalidOperationException) for when resources cannot be foundUnsupportedAzureScopeException(inheritsNotSupportedException) for unsupported scope typesthrow new Exception(...)with these specific exceptionsNote: Issue #1574 (SuccessHttpHandler) was already fixed in a previous commit that removed the class entirely.
Fixes #1578
Test plan
🤖 Generated with Claude Code