-
Notifications
You must be signed in to change notification settings - Fork 343
Throw fewer exceptions from AppLens #1472
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,7 +87,12 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context, | |
| options.Tenant, | ||
| cancellationToken); | ||
|
|
||
| context.Response.Results = ResponseResult.Create(new(result), AppLensJsonContext.Default.ResourceDiagnoseCommandResult); | ||
| context.Response.Results = result switch | ||
| { | ||
| Success<AppLensInsights> success => ResponseResult.Create(new(success.Data, Message: null), AppLensJsonContext.Default.ResourceDiagnoseCommandResult), | ||
| Failure<AppLensInsights> failure => ResponseResult.Create(new ResourceDiagnoseCommandResult(null, failure.Message), AppLensJsonContext.Default.ResourceDiagnoseCommandResult), | ||
| _ => throw new InvalidOperationException($"Unexpected result type from ${nameof(service.DiagnoseResourceAsync)}.") | ||
| }; | ||
|
Comment on lines
+90
to
+95
|
||
| } | ||
| catch (Exception ex) | ||
| { | ||
|
|
||
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.
The string interpolation syntax is incorrect. It uses
$followed by${nameof(...)}, which will not perform the interpolation correctly. The correct syntax should use{nameof(...)}inside a string prefixed with$. This will result in an error message that literally contains "${nameof(service.DiagnoseResourceAsync)}" instead of the actual method name "DiagnoseResourceAsync".