diff options
Diffstat (limited to '')
-rw-r--r-- | LibMatrix/Extensions/HttpClientExtensions.cs | 5 |
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); |