diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-10-13 13:09:27 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-10-13 13:09:27 +0200 |
commit | 2fa19a76b8f4ef72690f2d8ea0dd77ef2c5397da (patch) | |
tree | 8ac9d95c4077a552fcf7ad19231a56fe6edba93d /LibMatrix/Extensions | |
parent | Fix alias thing? (diff) | |
download | LibMatrix-2fa19a76b8f4ef72690f2d8ea0dd77ef2c5397da.tar.xz |
Error handling
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); |