From b2655a07d453e50278e5dabca03096121efccb68 Mon Sep 17 00:00:00 2001 From: John Tseng Date: Thu, 7 Sep 2017 17:51:53 -0500 Subject: [PATCH 1/2] fix error when method doesn't have a declaring type --- src/RollbarDotNet/Builder/ExceptionBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RollbarDotNet/Builder/ExceptionBuilder.cs b/src/RollbarDotNet/Builder/ExceptionBuilder.cs index 5bc7deb..471fbc8 100644 --- a/src/RollbarDotNet/Builder/ExceptionBuilder.cs +++ b/src/RollbarDotNet/Builder/ExceptionBuilder.cs @@ -54,7 +54,7 @@ protected List BuildFrames(Exception exception) : method.GetParameters() .Select(p => $"{p.ParameterType.FullName} {p.Name}") .Aggregate((p1, p2) => $"{p1}, {p2}"); - var methodName = $"{method.DeclaringType.FullName}.{method.Name}({parameters})"; + var methodName = $"{method.DeclaringType?.FullName ?? "(unknown)"}.{method.Name}({parameters})"; var frame = new Frame { Filename = stackTraceFrame.GetFileName(), From 6687cce269849c079ca7cd3d1bc2f37cfa4dc48f Mon Sep 17 00:00:00 2001 From: John Tseng Date: Thu, 7 Sep 2017 18:44:57 -0500 Subject: [PATCH 2/2] fix error when StackTrace.GetFrames returns null --- src/RollbarDotNet/Builder/ExceptionBuilder.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/RollbarDotNet/Builder/ExceptionBuilder.cs b/src/RollbarDotNet/Builder/ExceptionBuilder.cs index 471fbc8..5ff37d8 100644 --- a/src/RollbarDotNet/Builder/ExceptionBuilder.cs +++ b/src/RollbarDotNet/Builder/ExceptionBuilder.cs @@ -45,7 +45,12 @@ protected List BuildFrames(Exception exception) { var frames = new List(); var stacktrace = new StackTrace(exception, true); - foreach (var stackTraceFrame in stacktrace.GetFrames()) + var stackTraceFrames = stacktrace.GetFrames(); + if (stackTraceFrames == null) + { + return frames; + } + foreach (var stackTraceFrame in stackTraceFrames) { var method = stackTraceFrame.GetMethod(); var methodParameters = method.GetParameters();