mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-24 06:56:27 +00:00
32 lines
956 B
C#
32 lines
956 B
C#
using System.Globalization;
|
|
using System.Runtime.Serialization;
|
|
using System;
|
|
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));
|
|
|
|
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) { }
|
|
|
|
protected APITooManyRequestsException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
|
}
|
|
}
|