diff --git a/MaybeError/Errors/Error.cs b/MaybeError/Errors/Error.cs index 3654bd3..cede34b 100644 --- a/MaybeError/Errors/Error.cs +++ b/MaybeError/Errors/Error.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -18,15 +19,23 @@ public class Error(string message, string? details = null, string? devDetails = public readonly string? Details = details; public readonly string? DevDetails = devDetails; +#if DEBUG + private readonly StackTrace _stackTrace = new(); +#endif + public virtual Exception GetException() { +#if DEBUG + return new Exception(ToString()); +#else return new Exception(Message); +#endif } public override string ToString() { #if DEBUG - return $"{Message}\n{Details}\n{DevDetails}"; + return $"{Message}\n{Details}\n{DevDetails}\nTrace:{_stackTrace}"; #else return $"{Message}\n{Details}"; #endif diff --git a/MaybeError/MaybeError.csproj b/MaybeError/MaybeError.csproj index 203d4d7..6bfbaf7 100644 --- a/MaybeError/MaybeError.csproj +++ b/MaybeError/MaybeError.csproj @@ -8,7 +8,7 @@ MaybeError - 1.0.4 + 1.0.5 Amatsugu Errors as values https://github.com/Amatsugu/MaybeError