OpenBrowser returns false if it was unsuccessful

This commit is contained in:
Jonas Dellinger 2020-03-26 18:34:32 +01:00
parent 89c33bc728
commit 22d800d487
2 changed files with 28 additions and 19 deletions

View File

@ -1,3 +1,4 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
@ -5,7 +6,9 @@ namespace SpotifyAPI.Web.Auth
{
internal static class AuthUtil
{
public static void OpenBrowser(string url)
public static bool OpenBrowser(string url)
{
try
{
#if NETSTANDARD2_0
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@ -25,6 +28,12 @@ namespace SpotifyAPI.Web.Auth
url = url.Replace("&", "^&");
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
#endif
return true;
}
catch (Exception)
{
return false;
}
}
}
}

View File

@ -83,7 +83,7 @@ namespace SpotifyAPI.Web
/// <summary>
/// Error codes that will trigger auto-retry if <see cref="UseAutoRetry"/> is enabled.
/// </summary>
public IEnumerable<int> RetryErrorCodes { get; set; } = new [] { 500, 502, 503 };
public IEnumerable<int> RetryErrorCodes { get; set; } = new[] { 500, 502, 503 };
#endregion Configuration
@ -2873,7 +2873,7 @@ namespace SpotifyAPI.Web
private int GetTooManyRequests(ResponseInfo info)
{
// 429 is "TooManyRequests" value specified in Spotify API
if (429 != (int) info.StatusCode)
if (429 != (int)info.StatusCode)
{
return -1;
}