Fix nullability errors

This commit is contained in:
Tyrrrz
2021-11-08 23:16:37 +02:00
parent f456297881
commit 214d5e3bdb
20 changed files with 72 additions and 48 deletions

View File

@@ -0,0 +1,20 @@
using System;
using System.Text.Json;
namespace DiscordChatExporter.Core.Utils.Extensions
{
public static class JsonExtensions
{
public static string GetNonWhiteSpaceString(this JsonElement json)
{
if (json.ValueKind != JsonValueKind.String)
throw new FormatException();
var value = json.GetString();
if (string.IsNullOrWhiteSpace(value))
throw new FormatException();
return value;
}
}
}

View File

@@ -33,7 +33,7 @@ namespace DiscordChatExporter.Core.Utils
// on the very first request.
if (i > 3)
{
var retryAfterDelay = result.Result.Headers.RetryAfter.Delta;
var retryAfterDelay = result.Result.Headers.RetryAfter?.Delta;
if (retryAfterDelay is not null)
return retryAfterDelay.Value + TimeSpan.FromSeconds(1); // margin just in case
}