(feature): extract messages from exception
This commit is contained in:
parent
56b3ce84b4
commit
ab7fc58406
20
src/MaksIT.Core/Extensions/ExceptionExtensions.cs
Normal file
20
src/MaksIT.Core/Extensions/ExceptionExtensions.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
<!-- NuGet package metadata -->
|
||||
<PackageId>MaksIT.Core</PackageId>
|
||||
<Version>1.4.4</Version>
|
||||
<Version>1.4.5</Version>
|
||||
<Authors>Maksym Sadovnychyy</Authors>
|
||||
<Company>MAKS-IT</Company>
|
||||
<Product>MaksIT.Core</Product>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user