(feature): extract messages from exception

This commit is contained in:
Maksym Sadovnychyy 2025-07-25 21:36:57 +02:00
parent 56b3ce84b4
commit ab7fc58406
2 changed files with 21 additions and 1 deletions

View File

@ -0,0 +1,20 @@
namespace MaksIT.Core.Extensions;
public static class ExceptionExtensions {
/// <summary>
/// Extracts all messages from an exception and its inner exceptions.
/// </summary>
/// <param name="exception">The exception to extract messages from.</param>
/// <returns>A list of exception messages.</returns>
public static List<string> ExtractMessages(this Exception exception) {
var messages = new List<string>();
var current = exception;
while (current != null) {
messages.Add(current.Message);
current = current.InnerException;
}
return messages;
}
}

View File

@ -8,7 +8,7 @@
<!-- NuGet package metadata --> <!-- NuGet package metadata -->
<PackageId>MaksIT.Core</PackageId> <PackageId>MaksIT.Core</PackageId>
<Version>1.4.4</Version> <Version>1.4.5</Version>
<Authors>Maksym Sadovnychyy</Authors> <Authors>Maksym Sadovnychyy</Authors>
<Company>MAKS-IT</Company> <Company>MAKS-IT</Company>
<Product>MaksIT.Core</Product> <Product>MaksIT.Core</Product>