Skip to content

Commit

Permalink
Merge pull request #62 from johntseng/master
Browse files Browse the repository at this point in the history
fix error when method doesn't have a declaring type
  • Loading branch information
StrangeWill authored Oct 23, 2017
2 parents f47ad9f + 6687cce commit 69c73e5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/RollbarDotNet/Builder/ExceptionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ protected List<Frame> BuildFrames(Exception exception)
{
var frames = new List<Frame>();
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();
Expand All @@ -54,7 +59,7 @@ protected List<Frame> 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(),
Expand Down

0 comments on commit 69c73e5

Please sign in to comment.