The Free Software Media System - Server Backend & API
Do not handle exceptions manually when in development mode
Mark Monteiro842ec048284a
diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csprojindex f8560ca856..ae4f0bcf09 100644--- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj+++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj@@ -32,6 +32,7 @@<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.1" /><PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.1" /><PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.1" />+ <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.1" /><PackageReference Include="Mono.Nat" Version="2.0.0" /><PackageReference Include="ServiceStack.Text.Core" Version="5.8.0" /><PackageReference Include="sharpcompress" Version="0.24.0" />diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.csindex 49179a2dae..e8ea8d0339 100644--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs@@ -23,6 +23,7 @@ using MediaBrowser.Model.Services;using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.WebUtilities;using Microsoft.Extensions.Configuration;+using Microsoft.Extensions.Hosting;using Microsoft.Extensions.Logging;using ServiceStack.Text.Jsv;@@ -48,6 +49,8 @@ namespace Emby.Server.Implementations.HttpServerprivate readonly string _baseUrlPrefix;private readonly Dictionary<Type, Type> _serviceOperationsMap = new Dictionary<Type, Type>();private readonly List<IWebSocketConnection> _webSocketConnections = new List<IWebSocketConnection>();+ private readonly IHostEnvironment _hostEnvironment;+private IWebSocketListener[] _webSocketListeners = Array.Empty<IWebSocketListener>();private bool _disposed = false;@@ -60,7 +63,8 @@ namespace Emby.Server.Implementations.HttpServerIJsonSerializer jsonSerializer,IXmlSerializer xmlSerializer,IHttpListener socketListener,- ILocalizationManager localizationManager)+ ILocalizationManager localizationManager,+ IHostEnvironment hostEnvironment){_appHost = applicationHost;_logger = logger;@@ -72,6 +76,7 @@ namespace Emby.Server.Implementations.HttpServer_xmlSerializer = xmlSerializer;_socketListener = socketListener;_socketListener.WebSocketConnected = OnWebSocketConnected;+ _hostEnvironment = hostEnvironment;_funcParseFn = t => s => JsvReader.GetParseFn(t)(s);@@ -532,6 +537,13 @@ namespace Emby.Server.Implementations.HttpServer}catch (Exception ex){+ // Do not handle exceptions manually when in development mode+ // The framework-defined development exception page will be returned instead+ if (_hostEnvironment.IsDevelopment())+ {+ throw;+ }+bool ignoreStackTrace =ex is SocketException ||ex is IOException ||