using System.Text;

namespace Hcs.WebApp.Utils
{
    public static class ExceptionExtensions
    {
        public static string CombineMessages(this Exception e)
        {
            var stringBuilder = new StringBuilder();
            var currentException = e;
            while (currentException != null)
            {
                stringBuilder.AppendLine(currentException.Message);

                currentException = currentException.InnerException;
            }
            return stringBuilder.ToString();
        }
    }
}
