Skip to content

Commit a3cf602

Browse files
committed
Merge branch 'master' into push-to-client-sdks-oss-repos
2 parents ce85bc3 + bf49b8e commit a3cf602

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

DelveClientSDK/GeneratedDelveClient.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,26 +194,23 @@ protected virtual async System.Threading.Tasks.Task<ObjectResponseResult<T>> Rea
194194
}
195195
catch (Newtonsoft.Json.JsonException exception)
196196
{
197-
var message = "Could not deserialize the response body string as " + typeof(T).FullName + ".";
197+
var message = "Could not deserialize the response body string as " + typeof(T).FullName + "\n response content: " + responseText + ".";
198198
throw new ApiException(message, (int)response.StatusCode, responseText, headers, exception);
199199
}
200200
}
201201
else
202202
{
203+
var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
204+
var streamReader = new System.IO.StreamReader(responseStream);
205+
var streamText = streamReader.ReadToEnd();
203206
try
204207
{
205-
using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
206-
using (var streamReader = new System.IO.StreamReader(responseStream))
207-
using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader))
208-
{
209-
var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings);
210-
var typedBody = serializer.Deserialize<T>(jsonTextReader);
211-
return new ObjectResponseResult<T>(typedBody, string.Empty);
212-
}
208+
var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject<T>(streamText, JsonSerializerSettings);
209+
return new ObjectResponseResult<T>(typedBody, string.Empty);
213210
}
214211
catch (Newtonsoft.Json.JsonException exception)
215212
{
216-
var message = "Could not deserialize the response body stream as " + typeof(T).FullName + ".";
213+
var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "\n response content: " + streamText + ".";
217214
throw new ApiException(message, (int)response.StatusCode, string.Empty, headers, exception);
218215
}
219216
}

DelveClientSDK/GeneratedDelveCloudClient.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -625,26 +625,23 @@ protected virtual async System.Threading.Tasks.Task<ObjectResponseResult<T>> Rea
625625
}
626626
catch (Newtonsoft.Json.JsonException exception)
627627
{
628-
var message = "Could not deserialize the response body string as " + typeof(T).FullName + ".";
628+
var message = "Could not deserialize the response body string as " + typeof(T).FullName + "\n response content: " + responseText + ".";
629629
throw new ApiException(message, (int)response.StatusCode, responseText, headers, exception);
630630
}
631631
}
632632
else
633633
{
634+
var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
635+
var streamReader = new System.IO.StreamReader(responseStream);
636+
var streamText = streamReader.ReadToEnd();
634637
try
635638
{
636-
using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
637-
using (var streamReader = new System.IO.StreamReader(responseStream))
638-
using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader))
639-
{
640-
var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings);
641-
var typedBody = serializer.Deserialize<T>(jsonTextReader);
642-
return new ObjectResponseResult<T>(typedBody, string.Empty);
643-
}
639+
var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject<T>(streamText, JsonSerializerSettings);
640+
return new ObjectResponseResult<T>(typedBody, string.Empty);
644641
}
645642
catch (Newtonsoft.Json.JsonException exception)
646643
{
647-
var message = "Could not deserialize the response body stream as " + typeof(T).FullName + ".";
644+
var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "\n response content: " + streamText + ".";
648645
throw new ApiException(message, (int)response.StatusCode, string.Empty, headers, exception);
649646
}
650647
}

0 commit comments

Comments
 (0)