Microsoft.CodeAnalysis.Sarif.ExceptionData.Create C# (CSharp) Method

Create() public static method

public static Create ( Exception exception ) : ExceptionData
exception System.Exception
return ExceptionData
        public static ExceptionData Create(Exception exception)
        {
            return new ExceptionData
            {
                Kind = exception.GetType().Name,
                Message = exception.Message,
                InnerExceptions = GetInnerExceptions(exception),
                Stack = Stack.Create(exception.StackTrace)
            };
        }

Usage Example

Esempio n. 1
0
        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);
        }
All Usage Examples Of Microsoft.CodeAnalysis.Sarif.ExceptionData::Create