aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Browser/BrowserLauncher.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Browser/BrowserLauncher.cs')
-rw-r--r--Emby.Server.Implementations/Browser/BrowserLauncher.cs28
1 files changed, 13 insertions, 15 deletions
diff --git a/Emby.Server.Implementations/Browser/BrowserLauncher.cs b/Emby.Server.Implementations/Browser/BrowserLauncher.cs
index 752650ae1..96096e142 100644
--- a/Emby.Server.Implementations/Browser/BrowserLauncher.cs
+++ b/Emby.Server.Implementations/Browser/BrowserLauncher.cs
@@ -1,21 +1,21 @@
using System;
using MediaBrowser.Controller;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.Browser
{
/// <summary>
- /// Class BrowserLauncher.
+ /// Assists in opening application URLs in an external browser.
/// </summary>
public static class BrowserLauncher
{
/// <summary>
- /// Opens the web client.
+ /// Opens the home page of the web client.
/// </summary>
/// <param name="appHost">The app host.</param>
public static void OpenWebApp(IServerApplicationHost appHost)
{
- var url = appHost.GetLocalApiUrl("localhost") + "/web/index.html";
- OpenUrl(appHost, url);
+ TryOpenUrl(appHost, "/web/index.html");
}
/// <summary>
@@ -24,27 +24,25 @@ namespace Emby.Server.Implementations.Browser
/// <param name="appHost">The app host.</param>
public static void OpenSwaggerPage(IServerApplicationHost appHost)
{
- var url = appHost.GetLocalApiUrl("localhost") + "/swagger/index.html";
- OpenUrl(appHost, url);
+ TryOpenUrl(appHost, "/swagger/index.html");
}
/// <summary>
- /// Opens the URL.
+ /// Opens the specified URL in an external browser window. Any exceptions will be logged, but ignored.
/// </summary>
- /// <param name="appHost">The application host instance.</param>
+ /// <param name="appHost">The application host.</param>
/// <param name="url">The URL.</param>
- private static void OpenUrl(IServerApplicationHost appHost, string url)
+ private static void TryOpenUrl(IServerApplicationHost appHost, string url)
{
try
{
- appHost.LaunchUrl(url);
+ string baseUrl = appHost.GetLocalApiUrl("localhost");
+ appHost.LaunchUrl(baseUrl + url);
}
- catch (NotSupportedException)
- {
-
- }
- catch (Exception)
+ catch (Exception ex)
{
+ var logger = appHost.Resolve<ILogger>();
+ logger?.LogError(ex, "Failed to open browser window with URL {URL}", url);
}
}
}