Skip to content

Commit

Permalink
Make stacktrace of rp service exception shorter (#96)
Browse files Browse the repository at this point in the history
Remove unnecessary async
  • Loading branch information
nvborisenko authored Oct 22, 2022
1 parent efc1072 commit f84c6be
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 97 deletions.
16 changes: 8 additions & 8 deletions src/ReportPortal.Client/Resources/ServiceBaseResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ public ServiceBaseResource(HttpClient httpClient, string projectName)

protected string ProjectName { get; }

protected async Task<TResponse> GetAsJsonAsync<TResponse>(string uri, CancellationToken cancellationToken)
protected Task<TResponse> GetAsJsonAsync<TResponse>(string uri, CancellationToken cancellationToken)
{
return await SendAsJsonAsync<TResponse, object>(HttpMethod.Get, uri, null, cancellationToken).ConfigureAwait(false);
return SendAsJsonAsync<TResponse, object>(HttpMethod.Get, uri, null, cancellationToken);
}

protected async Task<TResponse> PostAsJsonAsync<TResponse, TRequest>(
protected Task<TResponse> PostAsJsonAsync<TResponse, TRequest>(
string uri, TRequest request, CancellationToken cancellationToken)
{
return await SendAsJsonAsync<TResponse, TRequest>(HttpMethod.Post, uri, request, cancellationToken).ConfigureAwait(false);
return SendAsJsonAsync<TResponse, TRequest>(HttpMethod.Post, uri, request, cancellationToken);
}

protected async Task<TResponse> PutAsJsonAsync<TResponse, TRequest>(
protected Task<TResponse> PutAsJsonAsync<TResponse, TRequest>(
string uri, TRequest request, CancellationToken cancellationToken)
{
return await SendAsJsonAsync<TResponse, TRequest>(HttpMethod.Put, uri, request, cancellationToken).ConfigureAwait(false);
return SendAsJsonAsync<TResponse, TRequest>(HttpMethod.Put, uri, request, cancellationToken);
}

protected async Task<TResponse> DeleteAsJsonAsync<TResponse>(string uri, CancellationToken cancellationToken)
protected Task<TResponse> DeleteAsJsonAsync<TResponse>(string uri, CancellationToken cancellationToken)
{
return await SendAsJsonAsync<TResponse, object>(HttpMethod.Delete, uri, null, cancellationToken).ConfigureAwait(false);
return SendAsJsonAsync<TResponse, object>(HttpMethod.Delete, uri, null, cancellationToken);
}

private async Task<TResponse> SendAsJsonAsync<TResponse, TRequest>(
Expand Down
52 changes: 26 additions & 26 deletions src/ReportPortal.Client/Resources/ServiceLaunchResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ public ServiceLaunchResource(HttpClient httpClient, string project) : base(httpC
{
}

public async Task<LaunchResponse> GetAsync(string uuid)
public Task<LaunchResponse> GetAsync(string uuid)
{
return await GetAsync(uuid, CancellationToken.None).ConfigureAwait(false);
return GetAsync(uuid, CancellationToken.None);
}

public async Task<LaunchResponse> GetAsync(string uuid, CancellationToken cancellationToken)
{
return await GetAsJsonAsync<LaunchResponse>($"{ProjectName}/launch/uuid/{uuid}", cancellationToken).ConfigureAwait(false);
}

public async Task<LaunchResponse> GetAsync(long id)
public Task<LaunchResponse> GetAsync(long id)
{
return await GetAsync(id, CancellationToken.None);
return GetAsync(id, CancellationToken.None);
}

public async Task<LaunchResponse> GetAsync(long id, CancellationToken cancellationToken)
{
return await GetAsJsonAsync<LaunchResponse>($"{ProjectName}/launch/{id}", cancellationToken).ConfigureAwait(false);
}

public async Task<LaunchCreatedResponse> StartAsync(StartLaunchRequest request)
public Task<LaunchCreatedResponse> StartAsync(StartLaunchRequest request)
{
return await StartAsync(request, CancellationToken.None).ConfigureAwait(false);
return StartAsync(request, CancellationToken.None);
}

public async Task<LaunchCreatedResponse> StartAsync(StartLaunchRequest request, CancellationToken cancellationToken)
Expand All @@ -45,9 +45,9 @@ public async Task<LaunchCreatedResponse> StartAsync(StartLaunchRequest request,
$"{ProjectName}/launch", request, cancellationToken).ConfigureAwait(false);
}

public async Task<LaunchFinishedResponse> FinishAsync(string uuid, FinishLaunchRequest request)
public Task<LaunchFinishedResponse> FinishAsync(string uuid, FinishLaunchRequest request)
{
return await FinishAsync(uuid, request, CancellationToken.None).ConfigureAwait(false);
return FinishAsync(uuid, request, CancellationToken.None);
}

public async Task<LaunchFinishedResponse> FinishAsync(string uuid, FinishLaunchRequest request, CancellationToken cancellationToken)
Expand All @@ -56,9 +56,9 @@ public async Task<LaunchFinishedResponse> FinishAsync(string uuid, FinishLaunchR
$"{ProjectName}/launch/{uuid}/finish", request, cancellationToken).ConfigureAwait(false);
}

public async Task<LaunchFinishedResponse> StopAsync(long id, FinishLaunchRequest request)
public Task<LaunchFinishedResponse> StopAsync(long id, FinishLaunchRequest request)
{
return await StopAsync(id, request, CancellationToken.None).ConfigureAwait(false);
return StopAsync(id, request, CancellationToken.None);
}

public async Task<LaunchFinishedResponse> StopAsync(long id, FinishLaunchRequest request, CancellationToken cancellationToken)
Expand All @@ -67,19 +67,19 @@ public async Task<LaunchFinishedResponse> StopAsync(long id, FinishLaunchRequest
$"{ProjectName}/launch/{id}/stop", request, cancellationToken).ConfigureAwait(false);
}

public async Task<MessageResponse> DeleteAsync(long id)
public Task<MessageResponse> DeleteAsync(long id)
{
return await DeleteAsync(id, CancellationToken.None).ConfigureAwait(false);
return DeleteAsync(id, CancellationToken.None);
}

public async Task<MessageResponse> DeleteAsync(long id, CancellationToken cancellationToken)
{
return await DeleteAsJsonAsync<MessageResponse>($"{ProjectName}/launch/{id}", cancellationToken).ConfigureAwait(false);
}

public async Task<LaunchResponse> MergeAsync(MergeLaunchesRequest request)
public Task<LaunchResponse> MergeAsync(MergeLaunchesRequest request)
{
return await MergeAsync(request, CancellationToken.None).ConfigureAwait(false);
return MergeAsync(request, CancellationToken.None);
}

public async Task<LaunchResponse> MergeAsync(MergeLaunchesRequest request, CancellationToken cancellationToken)
Expand All @@ -88,9 +88,9 @@ public async Task<LaunchResponse> MergeAsync(MergeLaunchesRequest request, Cance
$"{ProjectName}/launch/merge", request, cancellationToken).ConfigureAwait(false);
}

public async Task<MessageResponse> UpdateAsync(long id, UpdateLaunchRequest request)
public Task<MessageResponse> UpdateAsync(long id, UpdateLaunchRequest request)
{
return await UpdateAsync(id, request, CancellationToken.None).ConfigureAwait(false);
return UpdateAsync(id, request, CancellationToken.None);
}

public async Task<MessageResponse> UpdateAsync(long id, UpdateLaunchRequest request, CancellationToken cancellationToken)
Expand All @@ -99,9 +99,9 @@ public async Task<MessageResponse> UpdateAsync(long id, UpdateLaunchRequest requ
$"{ProjectName}/launch/{id}/update", request, cancellationToken).ConfigureAwait(false);
}

public async Task<MessageResponse> AnalyzeAsync(AnalyzeLaunchRequest request)
public Task<MessageResponse> AnalyzeAsync(AnalyzeLaunchRequest request)
{
return await AnalyzeAsync(request, CancellationToken.None).ConfigureAwait(false);
return AnalyzeAsync(request, CancellationToken.None);
}

public async Task<MessageResponse> AnalyzeAsync(AnalyzeLaunchRequest request, CancellationToken cancellationToken)
Expand All @@ -110,14 +110,14 @@ public async Task<MessageResponse> AnalyzeAsync(AnalyzeLaunchRequest request, Ca
$"{ProjectName}/launch/analyze", request, cancellationToken).ConfigureAwait(false);
}

public async Task<Content<LaunchResponse>> GetAsync()
public Task<Content<LaunchResponse>> GetAsync()
{
return await GetAsync(filterOption: null, CancellationToken.None).ConfigureAwait(false);
return GetAsync(filterOption: null, CancellationToken.None);
}

public async Task<Content<LaunchResponse>> GetAsync(FilterOption filterOption)
public Task<Content<LaunchResponse>> GetAsync(FilterOption filterOption)
{
return await GetAsync(filterOption, CancellationToken.None).ConfigureAwait(false);
return GetAsync(filterOption, CancellationToken.None);
}

public async Task<Content<LaunchResponse>> GetAsync(CancellationToken cancellationToken)
Expand All @@ -137,14 +137,14 @@ public async Task<Content<LaunchResponse>> GetAsync(FilterOption filterOption, C
return await GetAsJsonAsync<Content<LaunchResponse>>(uri, cancellationToken).ConfigureAwait(false);
}

public async Task<Content<LaunchResponse>> GetDebugAsync()
public Task<Content<LaunchResponse>> GetDebugAsync()
{
return await GetDebugAsync(filterOption: null, CancellationToken.None).ConfigureAwait(false);
return GetDebugAsync(filterOption: null, CancellationToken.None);
}

public async Task<Content<LaunchResponse>> GetDebugAsync(FilterOption filterOption)
public Task<Content<LaunchResponse>> GetDebugAsync(FilterOption filterOption)
{
return await GetDebugAsync(filterOption, CancellationToken.None).ConfigureAwait(false);
return GetDebugAsync(filterOption, CancellationToken.None);
}

public async Task<Content<LaunchResponse>> GetDebugAsync(CancellationToken cancellationToken)
Expand Down
32 changes: 16 additions & 16 deletions src/ReportPortal.Client/Resources/ServiceLogItemResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public ServiceLogItemResource(HttpClient httpClient, string project) : base(http
{
}

public async Task<Content<LogItemResponse>> GetAsync()
public Task<Content<LogItemResponse>> GetAsync()
{
return await GetAsync(filterOption: null, CancellationToken.None).ConfigureAwait(false);
return GetAsync(filterOption: null, CancellationToken.None);
}

public async Task<Content<LogItemResponse>> GetAsync(FilterOption filterOption)
public Task<Content<LogItemResponse>> GetAsync(FilterOption filterOption)
{
return await GetAsync(filterOption, CancellationToken.None).ConfigureAwait(false);
return GetAsync(filterOption, CancellationToken.None);
}

public async Task<Content<LogItemResponse>> GetAsync(CancellationToken cancellationToken)
Expand All @@ -46,39 +46,39 @@ public async Task<Content<LogItemResponse>> GetAsync(FilterOption filterOption,
return await GetAsJsonAsync<Content<LogItemResponse>>(uri, cancellationToken).ConfigureAwait(false);
}

public async Task<LogItemResponse> GetAsync(string uuid)
public Task<LogItemResponse> GetAsync(string uuid)
{
return await GetAsync(uuid, CancellationToken.None).ConfigureAwait(false);
return GetAsync(uuid, CancellationToken.None);
}

public async Task<LogItemResponse> GetAsync(string uuid, CancellationToken cancellationToken)
{
return await GetAsJsonAsync<LogItemResponse>($"{ProjectName}/log/uuid/{uuid}", cancellationToken).ConfigureAwait(false);
}

public async Task<LogItemResponse> GetAsync(long id)
public Task<LogItemResponse> GetAsync(long id)
{
return await GetAsync(id, CancellationToken.None).ConfigureAwait(false);
return GetAsync(id, CancellationToken.None);
}

public async Task<LogItemResponse> GetAsync(long id, CancellationToken cancellationToken)
{
return await GetAsJsonAsync<LogItemResponse>($"{ProjectName}/log/{id}", cancellationToken).ConfigureAwait(false);
}

public async Task<byte[]> GetBinaryDataAsync(string id)
public Task<byte[]> GetBinaryDataAsync(string id)
{
return await GetBinaryDataAsync(id, CancellationToken.None).ConfigureAwait(false);
return GetBinaryDataAsync(id, CancellationToken.None);
}

public async Task<byte[]> GetBinaryDataAsync(string id, CancellationToken cancellationToken)
{
return await GetAsBytesAsync($"data/{ProjectName}/{id}", cancellationToken).ConfigureAwait(false);
}

public async Task<LogItemCreatedResponse> CreateAsync(CreateLogItemRequest request)
public Task<LogItemCreatedResponse> CreateAsync(CreateLogItemRequest request)
{
return await CreateAsync(request, CancellationToken.None).ConfigureAwait(false);
return CreateAsync(request, CancellationToken.None);
}

public async Task<LogItemCreatedResponse> CreateAsync(CreateLogItemRequest request, CancellationToken cancellationToken)
Expand All @@ -96,9 +96,9 @@ public async Task<LogItemCreatedResponse> CreateAsync(CreateLogItemRequest reque
}
}

public async Task<LogItemsCreatedResponse> CreateAsync(CreateLogItemRequest[] requests)
public Task<LogItemsCreatedResponse> CreateAsync(CreateLogItemRequest[] requests)
{
return await CreateAsync(requests, CancellationToken.None).ConfigureAwait(false);
return CreateAsync(requests, CancellationToken.None);
}

public async Task<LogItemsCreatedResponse> CreateAsync(CreateLogItemRequest[] requests, CancellationToken cancellationToken)
Expand Down Expand Up @@ -130,9 +130,9 @@ public async Task<LogItemsCreatedResponse> CreateAsync(CreateLogItemRequest[] re
}
}

public async Task<MessageResponse> DeleteAsync(long id)
public Task<MessageResponse> DeleteAsync(long id)
{
return await DeleteAsync(id, CancellationToken.None).ConfigureAwait(false);
return DeleteAsync(id, CancellationToken.None);
}

public async Task<MessageResponse> DeleteAsync(long id, CancellationToken cancellationToken)
Expand Down
22 changes: 11 additions & 11 deletions src/ReportPortal.Client/Resources/ServiceProjectResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@ public ServiceProjectResource(HttpClient httpClient, string project) : base(http
{
}

public async Task<ProjectResponse> GetAsync()
public Task<ProjectResponse> GetAsync()
{
return await GetAsync(CancellationToken.None).ConfigureAwait(false);
return GetAsync(CancellationToken.None);
}

public async Task<ProjectResponse> GetAsync(CancellationToken cancellationToken)
{
return await GetAsJsonAsync<ProjectResponse>($"project/{ProjectName}", cancellationToken).ConfigureAwait(false);
}

public async Task<ProjectResponse> GetAsync(string projectName)
public Task<ProjectResponse> GetAsync(string projectName)
{
return await GetAsync(projectName, CancellationToken.None).ConfigureAwait(false);
return GetAsync(projectName, CancellationToken.None);
}

public async Task<ProjectResponse> GetAsync(string projectName, CancellationToken cancellationToken)
{
return await GetAsJsonAsync<ProjectResponse>($"project/{projectName}", cancellationToken).ConfigureAwait(false);
}

public async Task<MessageResponse> UpdatePreferencesAsync(string projectName, string userName, long filterId)
public Task<MessageResponse> UpdatePreferencesAsync(string projectName, string userName, long filterId)
{
return await UpdatePreferencesAsync(projectName, userName, filterId, CancellationToken.None).ConfigureAwait(false);
return UpdatePreferencesAsync(projectName, userName, filterId, CancellationToken.None);
}

public async Task<MessageResponse> UpdatePreferencesAsync(
Expand All @@ -47,16 +47,16 @@ public async Task<MessageResponse> UpdatePreferencesAsync(
cancellationToken).ConfigureAwait(false);
}

public Task<PreferenceResponse> GetAllPreferencesAsync(string projectName, string userName)
{
return GetAllPreferencesAsync(projectName, userName, CancellationToken.None);
}

public async Task<PreferenceResponse> GetAllPreferencesAsync(
string projectName, string userName, CancellationToken cancellationToken)
{
return await GetAsJsonAsync<PreferenceResponse>(
$"project/{projectName}/preference/{userName}", cancellationToken).ConfigureAwait(false);
}

public async Task<PreferenceResponse> GetAllPreferencesAsync(string projectName, string userName)
{
return await GetAllPreferencesAsync(projectName, userName, CancellationToken.None).ConfigureAwait(false);
}
}
}
Loading

0 comments on commit f84c6be

Please sign in to comment.