private static Notification CreateNotification(
Uri uri,
string notificationId,
string ruleId,
FailureLevel level,
Exception exception,
bool persistExceptionStack,
params string[] args)
{
string messageFormat = GetMessageFormatResourceForNotification(notificationId);
string message = string.Format(CultureInfo.CurrentCulture, messageFormat, args);
string exceptionMessage = exception?.Message;
if (!string.IsNullOrEmpty(exceptionMessage))
{
// {0} ('{1}')
message = string.Format(CultureInfo.InvariantCulture, SdkResources.NotificationWithExceptionMessage, message, exceptionMessage);
}
var exceptionData = exception != null && persistExceptionStack
? ExceptionData.Create(exception)
: null;
var physicalLocation = uri != null
? new PhysicalLocation
{
ArtifactLocation = new ArtifactLocation
{
Uri = uri
},
}
: null;
var notification = new Notification
{
PhysicalLocation = physicalLocation,
Id = notificationId,
RuleId = ruleId,
Level = level,
Message = new Message {
Text = message
},
Exception = exceptionData
};
return(notification);
}