You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using Nancy;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.ErrorManagment
|
|
|
|
|
{
|
|
|
|
|
public class ErrorPipeline
|
|
|
|
|
{
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public ErrorPipeline(Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Response HandleException(NancyContext context, Exception exception)
|
|
|
|
|
{
|
|
|
|
|
if (exception is ApiException)
|
|
|
|
|
{
|
|
|
|
|
_logger.WarnException("API Error", exception);
|
|
|
|
|
return ((ApiException)exception).ToErrorResponse();
|
|
|
|
|
}
|
|
|
|
|
_logger.ErrorException("Unexpected error", exception);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|