about summary refs log tree commit diff
path: root/LibMatrix/Extensions
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-13 13:09:27 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-13 13:09:27 +0200
commit2fa19a76b8f4ef72690f2d8ea0dd77ef2c5397da (patch)
tree8ac9d95c4077a552fcf7ad19231a56fe6edba93d /LibMatrix/Extensions
parentFix alias thing? (diff)
downloadLibMatrix-2fa19a76b8f4ef72690f2d8ea0dd77ef2c5397da.tar.xz
Error handling
Diffstat (limited to '')
-rw-r--r--LibMatrix/Extensions/HttpClientExtensions.cs5
1 files changed, 5 insertions, 0 deletions
diff --git a/LibMatrix/Extensions/HttpClientExtensions.cs b/LibMatrix/Extensions/HttpClientExtensions.cs
index 2faf0d5..62e9a98 100644
--- a/LibMatrix/Extensions/HttpClientExtensions.cs
+++ b/LibMatrix/Extensions/HttpClientExtensions.cs
@@ -48,6 +48,11 @@ public class MatrixHttpClient : HttpClient {
 
         //error handling
         var content = await a.Content.ReadAsStringAsync(cancellationToken);
+        if (content.Length == 0)
+            throw new MatrixException() {
+                ErrorCode = "M_UNKNOWN",
+                Error = "Unknown error, server returned no content"
+            };
         if (!content.StartsWith('{')) throw new InvalidDataException("Encountered invalid data:\n" + content);
         //we have a matrix error
         var ex = JsonSerializer.Deserialize<MatrixException>(content);