Files

24 lines
528 B
C#
Raw Permalink Normal View History

using System;
using System.Collections.Generic;
2025-02-16 11:54:23 +01:00
namespace Wino.Core.Domain.Extensions;
public static class ExceptionExtensions
{
2025-02-16 11:54:23 +01:00
public static IEnumerable<Exception> GetInnerExceptions(this Exception ex)
{
2025-02-16 11:54:23 +01:00
if (ex == null)
{
2025-02-16 11:54:23 +01:00
throw new ArgumentNullException("ex");
}
2025-02-16 11:54:23 +01:00
var innerException = ex;
do
{
yield return innerException;
innerException = innerException.InnerException;
}
2025-02-16 11:54:23 +01:00
while (innerException != null);
}
}