From dad41a224f7b2e36519743ef9e7e7c6692200e5d Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Mon, 11 Mar 2013 22:38:27 -0400 Subject: [PATCH] fixes #28 - Better info error when adding same path to media collection --- .../HttpServer/HttpServer.cs | 19 ++++++++++++++++--- .../ServerManager/ServerManager.cs | 3 +++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs index ee5009e21..0fc2c0dda 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs @@ -142,9 +142,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer DefaultRedirectPath = DefaultRedirectPath, // Tell SS to bubble exceptions up to here - WriteErrorsToResponse = false, - - DebugMode = true + WriteErrorsToResponse = false }); container.Adapter = new ContainerAdapter(ApplicationHost); @@ -153,6 +151,21 @@ namespace MediaBrowser.Server.Implementations.HttpServer Plugins.Add(new CorsFeature()); ServiceStack.Logging.LogManager.LogFactory = new NLogFactory(); + + ResponseFilters.Add((req, res, dto) => + { + var exception = dto as Exception; + + if (exception != null) + { + _logger.ErrorException("Error processing request", exception); + + if (!string.IsNullOrEmpty(exception.Message)) + { + res.AddHeader("X-Application-Error-Code", exception.Message); + } + } + }); } /// diff --git a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs index 60628853e..d97e39866 100644 --- a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs +++ b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs @@ -389,6 +389,8 @@ namespace MediaBrowser.Server.Implementations.ServerManager { if (UdpServer != null) { + _logger.Info("Disposing UdpServer"); + UdpServer.MessageReceived -= UdpServer_MessageReceived; UdpServer.Dispose(); } @@ -488,6 +490,7 @@ namespace MediaBrowser.Server.Implementations.ServerManager { if (ExternalWebSocketServer != null) { + _logger.Info("Disposing {0}", ExternalWebSocketServer.GetType().Name); ExternalWebSocketServer.Dispose(); } }