GetBaseException() public method

public GetBaseException ( ) : Exception
return Exception
コード例 #1
0
        internal static XElement Meta(AggregateException exception, string eventName)
        {
            var meta = new XElement("Meta",
                new XElement("Component", "Lokad.Cloud.Provisioning"),
                new XElement("Event", eventName));

            if (exception != null)
            {
                var ex = exception.GetBaseException();
                meta.Add(new XElement("Exception",
                    new XAttribute("typeName", ex.GetType().FullName),
                    new XAttribute("message", ex.Message),
                    ex.ToString()));
            }

            return meta;
        }
コード例 #2
0
        public static void BaseExceptions()
        {
            AggregateException ex = new AggregateException();
            Assert.Equal(ex.GetBaseException(), ex);

            Exception[] innerExceptions = new Exception[0];
            ex = new AggregateException(innerExceptions);
            Assert.Equal(ex.GetBaseException(), ex);

            innerExceptions = new Exception[1] { new AggregateException() };
            ex = new AggregateException(innerExceptions);
            Assert.Equal(ex.GetBaseException(), innerExceptions[0]);

            innerExceptions = new Exception[2] { new AggregateException(), new AggregateException() };
            ex = new AggregateException(innerExceptions);
            Assert.Equal(ex.GetBaseException(), ex);
        }
コード例 #3
0
        public static string GetAggregateErrorAsString(AggregateException ae)
        {
            Debug.WriteLine("ErrorFactory.GetAggregateErrorAsString()");

            var sb = new StringBuilder();
            sb.AppendLine("|AGGREGATE ERROR|");
            sb.AppendLine(GetErrorAsString(ae.GetBaseException()));
            sb.AppendLine("");

            foreach (var e in ae.InnerExceptions)
            {
                sb.AppendLine(GetErrorAsString(e));
                sb.AppendLine("");
            }

            return sb.ToString();
        }