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