aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-07-22 18:58:03 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-07-22 18:58:03 -0400
commitb41614ac81e113364080a2fe96e92723d50f4b06 (patch)
tree022bb1f69a566698d52ee2e26537f8cb4d4cf936 /Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
parentf0507b644d73dd324c841c358f59cb43befbf57a (diff)
update request logging
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/HttpListenerHost.cs')
-rw-r--r--Emby.Server.Implementations/HttpServer/HttpListenerHost.cs28
1 files changed, 27 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
index 28c23b766..05f78eba9 100644
--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -104,6 +104,7 @@ namespace Emby.Server.Implementations.HttpServer
readonly Dictionary<Type, int> _mapExceptionToStatusCode = new Dictionary<Type, int>
{
{typeof (ResourceNotFoundException), 404},
+ {typeof (RemoteServiceUnavailableException), 502},
{typeof (FileNotFoundException), 404},
//{typeof (DirectoryNotFoundException), 404},
{typeof (SecurityException), 401},
@@ -268,6 +269,29 @@ namespace Emby.Server.Implementations.HttpServer
}
}
+ private Exception GetActualException(Exception ex)
+ {
+ var agg = ex as AggregateException;
+ if (agg != null)
+ {
+ var inner = agg.InnerException;
+ if (inner != null)
+ {
+ return GetActualException(inner);
+ }
+ else
+ {
+ var inners = agg.InnerExceptions;
+ if (inners != null && inners.Count > 0)
+ {
+ return GetActualException(inners[0]);
+ }
+ }
+ }
+
+ return ex;
+ }
+
private int GetStatusCode(Exception ex)
{
if (ex is ArgumentException)
@@ -280,7 +304,7 @@ namespace Emby.Server.Implementations.HttpServer
int statusCode;
if (!_mapExceptionToStatusCode.TryGetValue(exceptionType, out statusCode))
{
- if (string.Equals(exceptionType.Name, "DirectoryNotFoundException", StringComparison.OrdinalIgnoreCase))
+ if (ex is DirectoryNotFoundException)
{
statusCode = 404;
}
@@ -297,6 +321,8 @@ namespace Emby.Server.Implementations.HttpServer
{
try
{
+ ex = GetActualException(ex);
+
if (logException)
{
_logger.ErrorException("Error processing request", ex);