Skip to content

Commit 5e96676

Browse files
authored
Add detailed debug logs on failed deserialization (#160)
1 parent b91a952 commit 5e96676

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Assets/Plugins/StreamChat/Core/LowLevelClient/API/Internal/InternalApiClientBase.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ private async Task<TResponse> HttpRequest<TResponse>(HttpMethodType httpMethod,
121121
catch (Exception e)
122122
{
123123
LogRestCall(uri, endpoint, httpMethod, responseContent, success: false, logContent);
124+
125+
#if STREAM_TESTS_ENABLED || STREAM_DEBUG_ENABLED
126+
var sb = new StringBuilder();
127+
sb.AppendLine("API Response Deserialization failed - StreamDeserializationException:");
128+
sb.AppendLine("Target type: " + typeof(APIErrorInternalDTO));
129+
sb.AppendLine("Content:");
130+
sb.AppendLine(responseContent);
131+
_logs.Error(sb.ToString());
132+
#endif
133+
124134
throw new StreamDeserializationException(responseContent, typeof(TResponse), e);
125135
}
126136

@@ -175,6 +185,16 @@ private async Task<TResponse> HttpRequest<TResponse>(HttpMethodType httpMethod,
175185
catch (Exception e)
176186
{
177187
LogRestCall(uri, endpoint, httpMethod, responseContent, success: false, logContent);
188+
189+
#if STREAM_TESTS_ENABLED || STREAM_DEBUG_ENABLED
190+
var sb = new StringBuilder();
191+
sb.AppendLine("API Response Deserialization failed - StreamDeserializationException:");
192+
sb.AppendLine("Target type: " + typeof(APIErrorInternalDTO));
193+
sb.AppendLine("Content:");
194+
sb.AppendLine(responseContent);
195+
_logs.Error(sb.ToString());
196+
#endif
197+
178198
throw new StreamDeserializationException(responseContent, typeof(TResponse), e);
179199
}
180200
}

0 commit comments

Comments
 (0)