Skip to content

Commit

Permalink
Null check when attempting to send null exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Fauchelle committed Jul 28, 2014
1 parent fe97d97 commit 78a358d
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Mindscape.Raygun4Net.Tests/RaygunClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ public void DontStripIfNoInnerException()
Assert.IsNull(message.Details.Error.InnerError);
}

[Test]
public void DontStripNull()
{
RaygunMessage message = _client.ExposeBuildMessage(null);
Assert.IsNull(message.Details.Error);
}

[Test]
public void StripMultipleWrapperExceptions()
{
Expand Down
2 changes: 1 addition & 1 deletion Mindscape.Raygun4Net.WinRT/RaygunClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private RaygunMessage BuildMessage(Exception exception, IList<string> tags, IDic

private static Exception StripWrapperExceptions(Exception exception)
{
if (_wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
if (exception != null && _wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
{
return StripWrapperExceptions(exception.InnerException);
}
Expand Down
2 changes: 1 addition & 1 deletion Mindscape.Raygun4Net.WindowsPhone/RaygunClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ private RaygunMessage BuildMessage(Exception exception, IList<string> tags, IDic

private static Exception StripWrapperExceptions(Exception exception)
{
if (_wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
if (exception != null && _wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
{
return StripWrapperExceptions(exception.InnerException);
}
Expand Down
2 changes: 1 addition & 1 deletion Mindscape.Raygun4Net.WindowsStore/RaygunClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ private string PackageVersion

private static Exception StripWrapperExceptions(Exception exception)
{
if (_wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
if (exception != null && _wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
{
return StripWrapperExceptions(exception.InnerException);
}
Expand Down
2 changes: 1 addition & 1 deletion Mindscape.Raygun4Net.Xamarin.Android/RaygunClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ internal RaygunMessage BuildMessage(Exception exception, IList<string> tags, IDi

private static Exception StripWrapperExceptions(Exception exception)
{
if (_wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
if (exception != null && _wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
{
return StripWrapperExceptions(exception.InnerException);
}
Expand Down
2 changes: 1 addition & 1 deletion Mindscape.Raygun4Net.Xamarin.iOS/RaygunClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ internal RaygunMessage BuildMessage(Exception exception, IList<string> tags, IDi

private static Exception StripWrapperExceptions(Exception exception)
{
if (_wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
if (exception != null && _wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
{
return StripWrapperExceptions(exception.InnerException);
}
Expand Down
2 changes: 1 addition & 1 deletion Mindscape.Raygun4Net/RaygunClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ protected RaygunMessage BuildMessage(Exception exception, IList<string> tags, ID

private static Exception StripWrapperExceptions(Exception exception)
{
if (_wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
if (exception != null && _wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
{
return StripWrapperExceptions(exception.InnerException);
}
Expand Down
7 changes: 7 additions & 0 deletions Mindscape.Raygun4Net2.Tests/RaygunClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ public void DontStripIfNoInnerException()
Assert.IsNull(message.Details.Error.InnerError);
}

[Test]
public void DontStripNull()
{
RaygunMessage message = _client.ExposeBuildMessage(null);
Assert.IsNull(message.Details.Error);
}

[Test]
public void StripMultipleWrapperExceptions()
{
Expand Down
2 changes: 1 addition & 1 deletion Mindscape.Raygun4Net2/RaygunClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ protected RaygunMessage BuildMessage(Exception exception, IList<string> tags, ID

private static Exception StripWrapperExceptions(Exception exception)
{
if (_wrapperExceptions.Contains(exception.GetType()) && exception.InnerException != null)
if (exception != null && _wrapperExceptions.Contains(exception.GetType()) && exception.InnerException != null)
{
return StripWrapperExceptions(exception.InnerException);
}
Expand Down

0 comments on commit 78a358d

Please sign in to comment.