From ae71314fde0e6ef45dea4c182c58009d64c737d2 Mon Sep 17 00:00:00 2001 From: laolarou Date: Sat, 16 Nov 2024 17:26:54 +0800 Subject: [PATCH] Update ErrorModel.cs --- .../Class/Model/YggdrasilAuth/ErrorModel.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ProjBobcat/ProjBobcat/Class/Model/YggdrasilAuth/ErrorModel.cs b/ProjBobcat/ProjBobcat/Class/Model/YggdrasilAuth/ErrorModel.cs index 22d28586..23ddcc49 100644 --- a/ProjBobcat/ProjBobcat/Class/Model/YggdrasilAuth/ErrorModel.cs +++ b/ProjBobcat/ProjBobcat/Class/Model/YggdrasilAuth/ErrorModel.cs @@ -1,4 +1,5 @@ using System; +using System.Text; using System.Text.Json.Serialization; namespace ProjBobcat.Class.Model.YggdrasilAuth; @@ -12,6 +13,22 @@ public class ErrorModel [JsonPropertyName("cause")] public string? Cause { get; init; } [JsonIgnore] public Exception? Exception { get; init; } + + public override string ToString() + { + var sb = new StringBuilder().AppendLine(); + + if (!string.IsNullOrEmpty(Error)) + sb.AppendLine("[ERROR]").AppendLine(Error); + if (!string.IsNullOrEmpty(ErrorMessage)) + sb.AppendLine("[ERROR MESSAGE]").AppendLine(ErrorMessage); + if (!string.IsNullOrEmpty(Cause)) + sb.AppendLine("[CAUSE]").AppendLine(Cause); + if (Exception != null) + sb.AppendLine("[EXCEPTION]").AppendLine(Exception.ToString()); + + return sb.AppendLine().ToString(); + } } [JsonSerializable(typeof(ErrorModel))]