Skip to content

Commit

Permalink
Update ErrorModel.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
laolarou726 committed Nov 16, 2024
1 parent 7065942 commit ae71314
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ProjBobcat/ProjBobcat/Class/Model/YggdrasilAuth/ErrorModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Text;
using System.Text.Json.Serialization;

namespace ProjBobcat.Class.Model.YggdrasilAuth;
Expand All @@ -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))]
Expand Down

0 comments on commit ae71314

Please sign in to comment.