2 files changed, 5 insertions, 2 deletions
diff --git a/MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs b/MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs
index 060867d..695e8e3 100644
--- a/MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs
+++ b/MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs
@@ -40,6 +40,7 @@ public class MatrixHttpClient : HttpClient {
var content = await a.Content.ReadAsStringAsync(cancellationToken);
if (content.StartsWith('{')) {
var ex = JsonSerializer.Deserialize<MatrixException>(content);
+ ex.RawContent = content;
Console.WriteLine($"Failed to send request: {ex}");
if (ex?.RetryAfterMs is not null) {
await Task.Delay(ex.RetryAfterMs.Value, cancellationToken);
@@ -61,4 +62,4 @@ public class MatrixHttpClient : HttpClient {
await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken);
return await JsonSerializer.DeserializeAsync<T>(responseStream, cancellationToken: cancellationToken);
}
-}
\ No newline at end of file
+}
diff --git a/MatrixRoomUtils.Core/MatrixException.cs b/MatrixRoomUtils.Core/MatrixException.cs
index 4795d6d..a469a62 100644
--- a/MatrixRoomUtils.Core/MatrixException.cs
+++ b/MatrixRoomUtils.Core/MatrixException.cs
@@ -16,6 +16,8 @@ public class MatrixException : Exception {
[JsonPropertyName("retry_after_ms")]
public int? RetryAfterMs { get; set; }
+ public string RawContent { get; set; }
+
public override string Message =>
$"{ErrorCode}: {ErrorCode switch {
// common
@@ -54,4 +56,4 @@ public class MatrixException : Exception {
"M_CANNOT_LEAVE_SERVER_NOTICE_ROOM" => $"Cannot leave server notice room: {Error}",
_ => $"Unknown error: {new { ErrorCode, Error, SoftLogout, RetryAfterMs }.ToJson(ignoreNull: true)}"
}}";
-}
\ No newline at end of file
+}
|