Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate required field Message with n/a if it is empty #2857

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,19 @@ public void DoesNotTrimShortExceptionMessages()
Assert.AreEqual(5, expDetails.message.Length);
}

[TestMethod]
[DataRow(null)]
[DataRow("")]
[DataRow(" ")]
public void ProvidesDefaultMessage(string message)
TimothyMothra marked this conversation as resolved.
Show resolved Hide resolved
NeilMountford marked this conversation as resolved.
Show resolved Hide resolved
{
var exp = new Exception(string.Empty);

ExceptionDetails expDetails = ExceptionConverter.ConvertToExceptionDetails(exp, null);

Assert.AreEqual("n/a", expDetails.message);
}

[MethodImplAttribute(MethodImplOptions.NoInlining)]
private Exception CreateException(int numberOfStackpoints)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External
{
using System;
using Microsoft.ApplicationInsights.DataContracts;

/// <summary>
/// Additional implementation for ExceptionDetails.
Expand All @@ -21,7 +22,7 @@ internal static ExceptionDetails CreateWithoutStackInfo(Exception exception, Exc
{
id = exception.GetHashCode(),
typeName = exception.GetType().FullName,
message = exception.Message,
message = Utils.PopulateRequiredStringValue(exception.Message, "message", typeof(ExceptionTelemetry).FullName),
NeilMountford marked this conversation as resolved.
Show resolved Hide resolved
};

if (parentExceptionDetails != null)
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## VNext
- [Populate required field Message with "n/a" if it is empty](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1066)

## Version 2.22.0
- no changes since beta.
Expand Down
Loading