about summary refs log tree commit diff
path: root/LibMatrix/MatrixException.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-01-04 01:50:27 +0100
committerRory& <root@rory.gay>2024-01-04 01:50:27 +0100
commit1b4c4956e3cd54d1701621bae5e2917365e0f5e1 (patch)
treef17b3f511ae5dd50c60fbf94ac95c8fc9e3a7044 /LibMatrix/MatrixException.cs
parentCleanup (diff)
downloadLibMatrix-1b4c4956e3cd54d1701621bae5e2917365e0f5e1.tar.xz
ToObject and ToJson for MatrixException
Diffstat (limited to '')
-rw-r--r--LibMatrix/MatrixException.cs5
1 files changed, 4 insertions, 1 deletions
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 =>