Skip to content

Commit

Permalink
Rework pb details exceptions on Edge connection string #790
Browse files Browse the repository at this point in the history
  • Loading branch information
hocinehacherouf committed Jun 15, 2022
1 parent 10107cc commit 71b38ad
Showing 1 changed file with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
@using AzureIoTHub.Portal.Client.Services
@using Microsoft.AspNetCore.Authorization
@using AzureIoTHub.Portal.Models.v10
@using AzureIoTHub.Portal.Models.v10

@inject HttpClient Http
@inject ISnackbar Snackbar
@inject ClipboardService ClipboardService

<div class="ConnectionString-dialog">
Expand Down Expand Up @@ -48,6 +45,9 @@
</div>

@code {
[CascadingParameter]
public Error Error {get; set;}

[CascadingParameter] MudDialogInstance MudDialog { get; set; }
[Parameter] public string deviceId { get; set; }
private EnrollmentCredentials Credentials;
Expand All @@ -59,23 +59,17 @@
{
await base.OnInitializedAsync();

Credentials = await this.Http.GetFromJsonAsync<EnrollmentCredentials>($"api/edge/devices/{deviceId}/credentials");
loading = false;

Credentials = await Http.GetFromJsonAsync<EnrollmentCredentials>($"api/edge/devices/{deviceId}/credentials");
}
catch (HttpRequestException e)
catch (ProblemDetailsException exception)
{
if (e.StatusCode == System.Net.HttpStatusCode.NotFound)
{
Snackbar.Add("Cannot obtain the connection string <br> because the enrollment group does not exist.", Severity.Error);
}
else
{
Snackbar.Add($"Something went wrong.", Severity.Error);
}

Error?.ProcessProblemDetails(exception);
MudDialog.Close();
}
finally
{
loading = false;
}
}


Expand Down

0 comments on commit 71b38ad

Please sign in to comment.