mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-30 19:50:15 -07:00
back to tiny for now
This commit is contained in:
parent
2912561d0e
commit
4deecde092
84 changed files with 617 additions and 558 deletions
|
@ -1,49 +0,0 @@
|
|||
using System;
|
||||
using FluentValidation;
|
||||
using NLog;
|
||||
using Nancy;
|
||||
using NzbDrone.Api.Extensions;
|
||||
|
||||
namespace NzbDrone.Api.ErrorManagement
|
||||
{
|
||||
public class ErrorPipeline
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
public ErrorPipeline(Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Response HandleException(NancyContext context, Exception exception)
|
||||
{
|
||||
var apiException = exception as ApiException;
|
||||
|
||||
if (apiException != null)
|
||||
{
|
||||
_logger.WarnException("API Error", apiException);
|
||||
return apiException.ToErrorResponse();
|
||||
}
|
||||
|
||||
var validationException = exception as ValidationException;
|
||||
|
||||
if (validationException != null)
|
||||
{
|
||||
_logger.Warn("Invalid request {0}", validationException.Message);
|
||||
|
||||
|
||||
return validationException.Errors.AsResponse(HttpStatusCode.BadRequest);
|
||||
|
||||
}
|
||||
|
||||
_logger.FatalException("Request Failed", exception);
|
||||
|
||||
|
||||
return new ErrorModel()
|
||||
{
|
||||
Message = exception.Message,
|
||||
Description = exception.ToString()
|
||||
}.AsResponse(HttpStatusCode.InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue