aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
blob: 7a37655a82831b86163b011ded04bdc56201f5e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.Logging
{
    /// <summary>
    /// Contains <see cref="Exception"/> exception methods.
    /// </summary>
    public static class ExceptionExtensions
    {
        /// <summary>
        /// Flattens the exception by digging on InnerException.
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <returns></returns>
        public static String FlattenException(this Exception exception)
        {
            var stringBuilder = new StringBuilder();

            while (exception != null)
            {
                stringBuilder.AppendLine(exception.Message);
                stringBuilder.AppendLine(exception.StackTrace);

                exception = exception.InnerException;
            }

            return stringBuilder.ToString();
        }
    }
}