about summary refs log tree commit diff
path: root/LibMatrix/Extensions
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-03-31 09:30:02 +0200
committerRory& <root@rory.gay>2025-03-31 09:30:22 +0200
commitfee33ee3ff27c3c89ff8a27701242b62334f8e58 (patch)
tree0b63d1beea6f7102e830487f937cdc376d305dfc /LibMatrix/Extensions
parentSplit out invite context, add empty filter constants (diff)
downloadLibMatrix-fee33ee3ff27c3c89ff8a27701242b62334f8e58.tar.xz
Propagate more HTTP errors, sync error handling callback
Diffstat (limited to 'LibMatrix/Extensions')
-rw-r--r--LibMatrix/Extensions/MatrixHttpClient.Single.cs15
1 files changed, 10 insertions, 5 deletions
diff --git a/LibMatrix/Extensions/MatrixHttpClient.Single.cs b/LibMatrix/Extensions/MatrixHttpClient.Single.cs

index afbe52f..bfc3f3b 100644 --- a/LibMatrix/Extensions/MatrixHttpClient.Single.cs +++ b/LibMatrix/Extensions/MatrixHttpClient.Single.cs
@@ -148,10 +148,10 @@ public class MatrixHttpClient { if (responseMessage.IsSuccessStatusCode) return responseMessage; //retry on gateway timeout - if (responseMessage.StatusCode == HttpStatusCode.GatewayTimeout) { - request.ResetSendStatus(); - return await SendAsync(request, cancellationToken); - } + // if (responseMessage.StatusCode == HttpStatusCode.GatewayTimeout) { + // request.ResetSendStatus(); + // return await SendAsync(request, cancellationToken); + // } //error handling var content = await responseMessage.Content.ReadAsStringAsync(cancellationToken); @@ -160,7 +160,12 @@ public class MatrixHttpClient { ErrorCode = "M_UNKNOWN", Error = "Unknown error, server returned no content" }; - if (!content.StartsWith('{')) throw new InvalidDataException("Encountered invalid data:\n" + content); + + // if (!content.StartsWith('{')) throw new InvalidDataException("Encountered invalid data:\n" + content); + if (!content.TrimStart().StartsWith('{')) { + responseMessage.EnsureSuccessStatusCode(); + throw new InvalidDataException("Encountered invalid data:\n" + content); + } //we have a matrix error MatrixException? ex;