Skip to content

Commit cb8dd18

Browse files
committed
refactored code
1 parent 5073a7f commit cb8dd18

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Src/NLog.Targets.Stackify/StackifyTarget.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,23 @@ internal LogMsg Translate(LogEventInfo loggingEvent)
271271
stackifyError = StackifyError.New(stringException);
272272
}
273273

274-
string stackifyHttp = StackifyHttpRequestInfo.Render(loggingEvent);
275-
if (stackifyError.WebRequestDetail == null && !String.IsNullOrEmpty(stackifyHttp))
274+
if (StackifyHttpRequestInfo != null)
276275
{
276+
string stackifyHttp = StackifyHttpRequestInfo.Render(loggingEvent);
277+
if (stackifyError.WebRequestDetail == null && !String.IsNullOrEmpty(stackifyHttp))
278+
{
277279
#if NETFULL
278-
var webRequestDetail = Newtonsoft.Json.JsonConvert.DeserializeObject<WebRequestDetail>(stackifyHttp);
279-
stackifyError.WebRequestDetail = webRequestDetail;
280+
try
281+
{
282+
var webRequestDetail = Newtonsoft.Json.JsonConvert.DeserializeObject<WebRequestDetail>(stackifyHttp);
283+
stackifyError.WebRequestDetail = webRequestDetail;
284+
}
285+
catch (Exception e)
286+
{
287+
InternalLogger.Warn(e, "StackifyHttpRequestInfo: Failed to DeserializeObject");
288+
}
280289
#endif
290+
}
281291
}
282292

283293
if (stackifyError != null && !StackifyError.IgnoreError(stackifyError) && _logClient.ErrorShouldBeSent(stackifyError))

0 commit comments

Comments
 (0)