From 1b4c4956e3cd54d1701621bae5e2917365e0f5e1 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 4 Jan 2024 01:50:27 +0100 Subject: ToObject and ToJson for MatrixException --- LibMatrix/MatrixException.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'LibMatrix/MatrixException.cs') diff --git a/LibMatrix/MatrixException.cs b/LibMatrix/MatrixException.cs index 10f0433..6a0f352 100644 --- a/LibMatrix/MatrixException.cs +++ b/LibMatrix/MatrixException.cs @@ -11,14 +11,17 @@ public class MatrixException : Exception { public required string Error { get; set; } [JsonPropertyName("soft_logout")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public bool? SoftLogout { get; set; } [JsonPropertyName("retry_after_ms")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public int? RetryAfterMs { get; set; } public string RawContent { get; set; } - public string? GetAsJson() => new { ErrorCode, Error, SoftLogout, RetryAfterMs }.ToJson(ignoreNull: true); + public object GetAsObject() => new { ErrorCode, Error, SoftLogout, RetryAfterMs }; + public string GetAsJson() => GetAsObject().ToJson(ignoreNull: true); public override string Message => -- cgit 1.4.1