diff options
author | Rory& <root@rory.gay> | 2024-01-04 01:50:27 +0100 |
---|---|---|
committer | Rory& <root@rory.gay> | 2024-01-04 01:50:27 +0100 |
commit | 1b4c4956e3cd54d1701621bae5e2917365e0f5e1 (patch) | |
tree | f17b3f511ae5dd50c60fbf94ac95c8fc9e3a7044 | |
parent | Cleanup (diff) | |
download | LibMatrix-1b4c4956e3cd54d1701621bae5e2917365e0f5e1.tar.xz |
ToObject and ToJson for MatrixException
-rw-r--r-- | LibMatrix/MatrixException.cs | 5 |
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 => |