Skip to content
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

Add HTTP status code in error logs #190

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions MangoPay.SDK/Core/RestTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ internal class RestTool
// key-value collection pass to the request
private Dictionary<string, string> _requestData;

// code get from response
private int _responseCode;

// pagination object
private Pagination _pagination;

Expand Down Expand Up @@ -260,18 +257,16 @@ private async Task<U> DoRequestAsync<U, T>(string urlMethod, T entity = default,
var restResponse = await _dto.Client.ExecuteAsync<U>(restRequest);
var responseObject = restResponse.Data;

this._responseCode = (int)restResponse.StatusCode;

if (restResponse.StatusCode == HttpStatusCode.OK || restResponse.StatusCode == HttpStatusCode.NoContent)
{
_log.Debug("Response OK: " + restResponse.Content);
}
else
{
_log.Debug("Response ERROR: " + restResponse.Content);
_log.Debug($"Response ERROR ({(int)restResponse.StatusCode}): " + restResponse.Content);
}

if (this._responseCode == 200)
if (restResponse.StatusCode == HttpStatusCode.OK)
{
_log.Debug("Response object: " + responseObject.ToString());
}
Expand Down Expand Up @@ -348,18 +343,16 @@ private async Task<ListPaginated<T>> DoRequestListAsync<T>(string urlMethod, Dic

responseObject = new ListPaginated<T>(restResponse.Data);

this._responseCode = (int)restResponse.StatusCode;

if (restResponse.StatusCode == HttpStatusCode.OK || restResponse.StatusCode == HttpStatusCode.NoContent)
{
_log.Debug("Response OK: " + restResponse.Content);
}
else
{
_log.Debug("Response ERROR: " + restResponse.Content);
_log.Debug($"Response ERROR ({(int)restResponse.StatusCode}): " + restResponse.Content);
}

if (this._responseCode == 200)
if (restResponse.StatusCode == HttpStatusCode.OK)
{
responseObject = this.ReadResponseHeaders<T>(restResponse, responseObject);

Expand Down
Loading