Spotify.NET/SpotifyAPI.Web/Exceptions/APITooManyRequestsException.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2022-11-27 12:29:35 +00:00
using System;
using System.Globalization;
using System.Runtime.Serialization;
using SpotifyAPI.Web.Http;
namespace SpotifyAPI.Web
{
[Serializable]
public class APITooManyRequestsException : APIException
{
public TimeSpan RetryAfter { get; }
public APITooManyRequestsException(IResponse response) : base(response)
{
Ensure.ArgumentNotNull(response, nameof(response));
2020-11-13 13:43:00 +00:00
if (response.Headers.TryGetValue("Retry-After", out string? retryAfter))
{
RetryAfter = TimeSpan.FromSeconds(int.Parse(retryAfter, CultureInfo.InvariantCulture));
}
}
public APITooManyRequestsException() { }
public APITooManyRequestsException(string message) : base(message) { }
public APITooManyRequestsException(string message, Exception innerException) : base(message, innerException) { }
2024-02-10 10:56:20 +00:00
#if NET8_0_OR_GREATER
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
#endif
protected APITooManyRequestsException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}