Skip to content

Commit 64fca05

Browse files
give better error message when create continuous export failed
1 parent 314c137 commit 64fca05

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/ResourceManager/ApplicationInsights/Commands.ApplicationInsights/ApplicationInsights/NewApplicationInsightsContinuousExport.cs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,28 @@ public override void ExecuteCmdlet()
120120

121121
if (this.ShouldProcess(this.Name, "Create Application Insights Continuous Export"))
122122
{
123-
var exportConfigurationsResponse = this.AppInsightsManagementClient
124-
.ExportConfigurations
125-
.CreateWithHttpMessagesAsync(
126-
this.ResourceGroupName,
127-
this.Name,
128-
exportRequest)
129-
.GetAwaiter()
130-
.GetResult();
131-
132-
WriteComponentExportConfiguration(exportConfigurationsResponse.Body.FirstOrDefault());
123+
try
124+
{
125+
var exportConfigurationsResponse = this.AppInsightsManagementClient
126+
.ExportConfigurations
127+
.CreateWithHttpMessagesAsync(
128+
this.ResourceGroupName,
129+
this.Name,
130+
exportRequest)
131+
.GetAwaiter()
132+
.GetResult();
133+
134+
WriteComponentExportConfiguration(exportConfigurationsResponse.Body.FirstOrDefault());
135+
}
136+
catch (Microsoft.Rest.Azure.CloudException exception)
137+
{
138+
if (exception.Response != null && exception.Response.StatusCode == System.Net.HttpStatusCode.Conflict)
139+
{
140+
throw new System.Exception("There is already an export defined for this destination.");
141+
}
142+
143+
throw exception;
144+
}
133145
}
134146
}
135147
}

0 commit comments

Comments
 (0)