diff --git a/src/MaksIT.Core/Extensions/ExceptionExtensions.cs b/src/MaksIT.Core/Extensions/ExceptionExtensions.cs new file mode 100644 index 0000000..af25f6b --- /dev/null +++ b/src/MaksIT.Core/Extensions/ExceptionExtensions.cs @@ -0,0 +1,20 @@ +namespace MaksIT.Core.Extensions; + +public static class ExceptionExtensions { + /// + /// Extracts all messages from an exception and its inner exceptions. + /// + /// The exception to extract messages from. + /// A list of exception messages. + public static List ExtractMessages(this Exception exception) { + var messages = new List(); + var current = exception; + + while (current != null) { + messages.Add(current.Message); + current = current.InnerException; + } + + return messages; + } +} diff --git a/src/MaksIT.Core/MaksIT.Core.csproj b/src/MaksIT.Core/MaksIT.Core.csproj index 2dbbb13..7618d49 100644 --- a/src/MaksIT.Core/MaksIT.Core.csproj +++ b/src/MaksIT.Core/MaksIT.Core.csproj @@ -8,7 +8,7 @@ MaksIT.Core - 1.4.4 + 1.4.5 Maksym Sadovnychyy MAKS-IT MaksIT.Core