Error handling and fixes
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||
<PackageReference Include="Blazor.Bootstrap" Version="3.0.0" />
|
||||
<PackageReference Include="FluentValidation" Version="11.9.2" />
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.DataAnnotations.Validation" Version="3.2.0-rc1.20223.4" />
|
||||
@@ -22,6 +23,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<_ContentIncludedByDefault Remove="wwwroot\sample-data\weather.json" />
|
||||
<_ContentIncludedByDefault Remove="wwwroot\css\bootstrap\bootstrap.min.css" />
|
||||
<_ContentIncludedByDefault Remove="wwwroot\css\bootstrap\bootstrap.min.css.map" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,26 +1,52 @@
|
||||
@using System.Net
|
||||
@using BlazorWebAssemblyVisaApiClient.Common.Exceptions
|
||||
@using VisaApiClient
|
||||
|
||||
<CascadingValue Value="this">
|
||||
<Modal @ref="modal">
|
||||
<BodyTemplate>
|
||||
@errorDetails
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="modal.HideAsync">Okaaaay</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
@ChildContent
|
||||
</CascadingValue>
|
||||
|
||||
@code
|
||||
{
|
||||
[Parameter]
|
||||
public RenderFragment? ChildContent { get; set; }
|
||||
private Modal modal = null!;
|
||||
private string errorDetails = null!;
|
||||
|
||||
[Parameter] public RenderFragment? ChildContent { get; set; }
|
||||
|
||||
[Inject] private NavigationManager Nav { get; set; } = null!;
|
||||
|
||||
public void Handle(Exception ex)
|
||||
{
|
||||
if (ex is ApiException<ProblemDetails>
|
||||
switch (ex)
|
||||
{
|
||||
case ApiException<ProblemDetails>
|
||||
{
|
||||
StatusCode: (int)HttpStatusCode.Unauthorized or (int)HttpStatusCode.Forbidden
|
||||
}
|
||||
or NotLoggedInException)
|
||||
{
|
||||
Nav.NavigateTo("/");
|
||||
} or NotLoggedInException:
|
||||
Nav.NavigateTo("/");
|
||||
modal.Title = "Authorization failed";
|
||||
errorDetails = "You are not authorized or your authorization is expired";
|
||||
break;
|
||||
|
||||
case ApiException<ProblemDetails> problemDetails:
|
||||
modal.Title = problemDetails.Result.Title!;
|
||||
errorDetails = problemDetails.Result.Detail!;
|
||||
modal.ShowAsync();
|
||||
break;
|
||||
|
||||
default:
|
||||
modal.Title = "Something went wrong";
|
||||
errorDetails = "Please, text an email with your problem definition on nasrudin@mail.ru";
|
||||
modal.ShowAsync();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@page "/applications/{ApplicationId}"
|
||||
@using BlazorWebAssemblyVisaApiClient.Common.Exceptions
|
||||
@using BlazorWebAssemblyVisaApiClient.Components
|
||||
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
|
||||
@using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
|
||||
@using VisaApiClient
|
||||
@@ -175,15 +176,24 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@if (currentRole == Constants.ApprovingAuthorityRole)
|
||||
{
|
||||
<button class="btn-outline-primary" @onclick="Approve">Approve</button>
|
||||
<button class="btn-outline-danger" @onclick="Reject">Reject</button>
|
||||
<Status @ref="status"/>
|
||||
}
|
||||
|
||||
@code {
|
||||
private VisaApplicationModel application = new();
|
||||
private string currentRole = null!;
|
||||
private Status status = null!;
|
||||
|
||||
[Parameter] public string ApplicationId { get; set; } = null!;
|
||||
|
||||
[Inject] private IUserDataProvider UserDataProvider { get; set; } = null!;
|
||||
|
||||
[Inject] private NavigationManager Nav { get; set; } = null!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
@@ -191,12 +201,12 @@
|
||||
var applicationId = Guid.Parse(ApplicationId);
|
||||
currentRole = UserDataProvider.GetCurrentRole() ?? throw new NotLoggedInException();
|
||||
|
||||
application = currentRole switch
|
||||
{
|
||||
Constants.ApplicantRole => await Client.GetApplicationForApplicantAsync(applicationId),
|
||||
Constants.ApprovingAuthorityRole => await Client.GetApplicationForAuthorityAsync(applicationId),
|
||||
_ => throw new NotLoggedInException()
|
||||
};
|
||||
application = currentRole switch
|
||||
{
|
||||
Constants.ApplicantRole => await Client.GetApplicationForApplicantAsync(applicationId),
|
||||
Constants.ApprovingAuthorityRole => await Client.GetApplicationForAuthorityAsync(applicationId),
|
||||
_ => throw new NotLoggedInException()
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -210,4 +220,34 @@
|
||||
private static string AddressToString(AddressModel address)
|
||||
=> $"{address.Country}, {address.City}, {address.Street} {address.Building}";
|
||||
|
||||
private async void Approve()
|
||||
{
|
||||
try
|
||||
{
|
||||
status.SetMessage("Wait...");
|
||||
await Client.SetStatusFromAuthorityAsync(application.Id, AuthorityRequestStatuses.Approved);
|
||||
Nav.NavigateTo("/applications");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
status.SetError("Error occured.");
|
||||
ErrorHandler.Handle(e);
|
||||
}
|
||||
}
|
||||
|
||||
private async void Reject()
|
||||
{
|
||||
try
|
||||
{
|
||||
status.SetMessage("Wait...");
|
||||
await Client.SetStatusFromAuthorityAsync(application.Id, AuthorityRequestStatuses.Rejected);
|
||||
Nav.NavigateTo("/applications");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
status.SetError("Error occured.");
|
||||
ErrorHandler.Handle(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<NavLink href="@($"/applications/{application.Id}")">
|
||||
<button class="btn-outline-primary">See</button>
|
||||
</NavLink>
|
||||
@if (currentRole == Constants.ApplicantRole && application.Status is not ApplicationStatus.Closed)
|
||||
@if (currentRole == Constants.ApplicantRole && application.Status is ApplicationStatus.Pending)
|
||||
{
|
||||
<span> | </span>
|
||||
<input type="button" class="border-danger" @onclick="() => CloseApplication(application)" value="Close"/>
|
||||
@@ -70,7 +70,7 @@
|
||||
{
|
||||
applications = currentRole switch
|
||||
{
|
||||
Constants.ApplicantRole => (await Client.GetForApplicantAsync()).OrderByDescending(a => a.RequestDate).ToList(),
|
||||
Constants.ApplicantRole => (await Client.GetApplicationsForApplicantAsync()).OrderByDescending(a => a.RequestDate).ToList(),
|
||||
Constants.ApprovingAuthorityRole => (await Client.GetPendingAsync()).OrderByDescending(a => a.RequestDate).ToList(),
|
||||
_ => throw new NotLoggedInException()
|
||||
};
|
||||
|
||||
@@ -267,7 +267,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorHandler.Handle(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -172,7 +172,6 @@
|
||||
if (errorsList is null)
|
||||
{
|
||||
ErrorHandler.Handle(new JsonException("Can't convert validation errors to list"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -180,7 +179,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorHandler.Handle(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -21,6 +21,7 @@ public class Program
|
||||
|
||||
//todo make pretty
|
||||
builder.Services.AddScoped(_ => new HttpClient { BaseAddress = new Uri(baseAddress) });
|
||||
builder.Services.AddBlazorBootstrap();
|
||||
builder.Services.AddScoped<Client>(sp => new Client(baseAddress, sp.GetRequiredService<HttpClient>()));
|
||||
|
||||
builder.Services.AddSingleton<IDateTimeProvider, DateTimeProvider>();
|
||||
|
||||
@@ -8,3 +8,4 @@
|
||||
@using Microsoft.JSInterop
|
||||
@using BlazorWebAssemblyVisaApiClient
|
||||
@using BlazorWebAssemblyVisaApiClient.Layout
|
||||
@using BlazorBootstrap
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
<title>BlazorWebAssemblyVisaApiClient</title>
|
||||
<base href="/" />
|
||||
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet" />
|
||||
<link href="_content/Blazor.Bootstrap/blazor.bootstrap.css" rel="stylesheet" />
|
||||
<link rel="stylesheet" href="css/app.css" />
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<link href="BlazorWebAssemblyVisaApiClient.styles.css" rel="stylesheet" />
|
||||
@@ -27,6 +30,14 @@
|
||||
<a class="dismiss">🗙</a>
|
||||
</div>
|
||||
<script src="_framework/blazor.webassembly.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||
<!-- Add chart.js reference if chart components are used in your application. -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.0.1/chart.umd.js" integrity="sha512-gQhCDsnnnUfaRzD8k1L5llCCV6O9HN09zClIzzeJ8OJ9MpGmIlCxm+pdCkqTwqJ4JcjbojFr79rl2F1mzcoLMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<!-- Add chartjs-plugin-datalabels.min.js reference if chart components with data label feature is used in your application. -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.2.0/chartjs-plugin-datalabels.min.js" integrity="sha512-JPcRR8yFa8mmCsfrw4TNte1ZvF1e3+1SdGMslZvmrzDYxS69J7J49vkFL8u6u8PlPJK+H3voElBtUCzaXj+6ig==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<!-- Add sortable.js reference if SortableList component is used in your application. -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
|
||||
<script src="_content/Blazor.Bootstrap/blazor.bootstrap.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -35,6 +35,7 @@ public class VisaApplicationController(
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||
[Authorize(policy: PolicyConstants.ApprovingAuthorityPolicy)]
|
||||
public async Task<IActionResult> GetApplicationForAuthority(Guid applicationId, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -60,11 +61,11 @@ public class VisaApplicationController(
|
||||
/// <remarks> Returns applications of authorized applicant </remarks>
|
||||
[HttpGet("ofApplicant")]
|
||||
[ProducesResponseType<List<VisaApplicationPreview>>(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[Authorize(policy: PolicyConstants.ApplicantPolicy)]
|
||||
public async Task<IActionResult> GetForApplicant(CancellationToken cancellationToken)
|
||||
public async Task<IActionResult> GetApplicationsForApplicant(CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await visaApplicationRequestsHandler.GetForApplicantAsync(cancellationToken);
|
||||
return Ok(result);
|
||||
@@ -74,10 +75,10 @@ public class VisaApplicationController(
|
||||
/// <remarks> Adds application for authorized applicant </remarks>
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[Authorize(policy: PolicyConstants.ApplicantPolicy)]
|
||||
public async Task<IActionResult> CreateApplication(VisaApplicationCreateRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -91,10 +92,10 @@ public class VisaApplicationController(
|
||||
/// <remarks> Accessible only for applicant</remarks>
|
||||
[HttpPatch("{applicationId:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[Authorize(policy: PolicyConstants.ApplicantPolicy)]
|
||||
public async Task<IActionResult> CloseApplication(Guid applicationId, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -106,9 +107,10 @@ public class VisaApplicationController(
|
||||
/// <remarks> Accessible only for authorities</remarks>
|
||||
[HttpPatch("approving/{applicationId:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||
[Authorize(policy: PolicyConstants.ApprovingAuthorityPolicy)]
|
||||
public async Task<IActionResult> SetStatusFromAuthority(Guid applicationId,
|
||||
AuthorityRequestStatuses status,
|
||||
|
||||
@@ -1061,6 +1061,16 @@ namespace VisaApiClient
|
||||
throw new ApiException<ProblemDetails>("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 409)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
if (objectResponse_.Object == null)
|
||||
{
|
||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||
}
|
||||
throw new ApiException<ProblemDetails>("Conflict", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
|
||||
@@ -1212,9 +1222,9 @@ namespace VisaApiClient
|
||||
/// </remarks>
|
||||
/// <returns>Success</returns>
|
||||
/// <exception cref="ApiException">A server side error occurred.</exception>
|
||||
public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<VisaApplicationPreview>> GetForApplicantAsync()
|
||||
public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<VisaApplicationPreview>> GetApplicationsForApplicantAsync()
|
||||
{
|
||||
return GetForApplicantAsync(System.Threading.CancellationToken.None);
|
||||
return GetApplicationsForApplicantAsync(System.Threading.CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
|
||||
@@ -1226,7 +1236,7 @@ namespace VisaApiClient
|
||||
/// </remarks>
|
||||
/// <returns>Success</returns>
|
||||
/// <exception cref="ApiException">A server side error occurred.</exception>
|
||||
public virtual async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<VisaApplicationPreview>> GetForApplicantAsync(System.Threading.CancellationToken cancellationToken)
|
||||
public virtual async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<VisaApplicationPreview>> GetApplicationsForApplicantAsync(System.Threading.CancellationToken cancellationToken)
|
||||
{
|
||||
var client_ = _httpClient;
|
||||
var disposeClient_ = false;
|
||||
@@ -1275,16 +1285,6 @@ namespace VisaApiClient
|
||||
return objectResponse_.Object;
|
||||
}
|
||||
else
|
||||
if (status_ == 403)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
if (objectResponse_.Object == null)
|
||||
{
|
||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||
}
|
||||
throw new ApiException<ProblemDetails>("Forbidden", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 401)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
@@ -1295,6 +1295,16 @@ namespace VisaApiClient
|
||||
throw new ApiException<ProblemDetails>("Unauthorized", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 403)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
if (objectResponse_.Object == null)
|
||||
{
|
||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||
}
|
||||
throw new ApiException<ProblemDetails>("Forbidden", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 404)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
@@ -1393,14 +1403,14 @@ namespace VisaApiClient
|
||||
return;
|
||||
}
|
||||
else
|
||||
if (status_ == 403)
|
||||
if (status_ == 400)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
if (objectResponse_.Object == null)
|
||||
{
|
||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||
}
|
||||
throw new ApiException<ProblemDetails>("Forbidden", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
throw new ApiException<ProblemDetails>("Bad Request", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 401)
|
||||
@@ -1413,6 +1423,16 @@ namespace VisaApiClient
|
||||
throw new ApiException<ProblemDetails>("Unauthorized", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 403)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
if (objectResponse_.Object == null)
|
||||
{
|
||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||
}
|
||||
throw new ApiException<ProblemDetails>("Forbidden", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 404)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
@@ -1423,16 +1443,6 @@ namespace VisaApiClient
|
||||
throw new ApiException<ProblemDetails>("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 400)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
if (objectResponse_.Object == null)
|
||||
{
|
||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||
}
|
||||
throw new ApiException<ProblemDetails>("Bad Request", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
|
||||
@@ -1522,14 +1532,14 @@ namespace VisaApiClient
|
||||
return;
|
||||
}
|
||||
else
|
||||
if (status_ == 403)
|
||||
if (status_ == 400)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
if (objectResponse_.Object == null)
|
||||
{
|
||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||
}
|
||||
throw new ApiException<ProblemDetails>("Forbidden", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
throw new ApiException<ProblemDetails>("Bad Request", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 401)
|
||||
@@ -1542,6 +1552,16 @@ namespace VisaApiClient
|
||||
throw new ApiException<ProblemDetails>("Unauthorized", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 403)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
if (objectResponse_.Object == null)
|
||||
{
|
||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||
}
|
||||
throw new ApiException<ProblemDetails>("Forbidden", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 404)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
@@ -1552,16 +1572,6 @@ namespace VisaApiClient
|
||||
throw new ApiException<ProblemDetails>("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 400)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
if (objectResponse_.Object == null)
|
||||
{
|
||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||
}
|
||||
throw new ApiException<ProblemDetails>("Bad Request", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
|
||||
@@ -1657,16 +1667,6 @@ namespace VisaApiClient
|
||||
return;
|
||||
}
|
||||
else
|
||||
if (status_ == 403)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
if (objectResponse_.Object == null)
|
||||
{
|
||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||
}
|
||||
throw new ApiException<ProblemDetails>("Forbidden", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 401)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
@@ -1677,6 +1677,16 @@ namespace VisaApiClient
|
||||
throw new ApiException<ProblemDetails>("Unauthorized", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 403)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
if (objectResponse_.Object == null)
|
||||
{
|
||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||
}
|
||||
throw new ApiException<ProblemDetails>("Forbidden", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 404)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
@@ -1687,6 +1697,16 @@ namespace VisaApiClient
|
||||
throw new ApiException<ProblemDetails>("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
if (status_ == 409)
|
||||
{
|
||||
var objectResponse_ = await ReadObjectResponseAsync<ProblemDetails>(response_, headers_, cancellationToken).ConfigureAwait(false);
|
||||
if (objectResponse_.Object == null)
|
||||
{
|
||||
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
|
||||
}
|
||||
throw new ApiException<ProblemDetails>("Conflict", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user