mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
Fixed error pipeline.
This commit is contained in:
parent
28c6a69e0f
commit
e67a805925
@ -17,11 +17,10 @@ public NzbDroneErrorPipeline(Logger logger)
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Response HandleException(NancyContext context, Exception aggregateException)
|
public Response HandleException(NancyContext context, Exception exception)
|
||||||
{
|
{
|
||||||
var innerException = (aggregateException.InnerException).InnerException;
|
|
||||||
|
|
||||||
var apiException = innerException as ApiException;
|
var apiException = exception as ApiException;
|
||||||
|
|
||||||
if (apiException != null)
|
if (apiException != null)
|
||||||
{
|
{
|
||||||
@ -29,7 +28,7 @@ public Response HandleException(NancyContext context, Exception aggregateExcepti
|
|||||||
return apiException.ToErrorResponse();
|
return apiException.ToErrorResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
var validationException = innerException as ValidationException;
|
var validationException = exception as ValidationException;
|
||||||
|
|
||||||
if (validationException != null)
|
if (validationException != null)
|
||||||
{
|
{
|
||||||
@ -38,23 +37,23 @@ public Response HandleException(NancyContext context, Exception aggregateExcepti
|
|||||||
return validationException.Errors.AsResponse(HttpStatusCode.BadRequest);
|
return validationException.Errors.AsResponse(HttpStatusCode.BadRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clientException = innerException as NzbDroneClientException;
|
var clientException = exception as NzbDroneClientException;
|
||||||
|
|
||||||
if (clientException != null)
|
if (clientException != null)
|
||||||
{
|
{
|
||||||
return new ErrorModel
|
return new ErrorModel
|
||||||
{
|
{
|
||||||
Message = innerException.Message,
|
Message = exception.Message,
|
||||||
Description = innerException.ToString()
|
Description = exception.ToString()
|
||||||
}.AsResponse((HttpStatusCode)clientException.StatusCode);
|
}.AsResponse((HttpStatusCode)clientException.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.FatalException("Request Failed", innerException);
|
_logger.FatalException("Request Failed", exception);
|
||||||
|
|
||||||
return new ErrorModel
|
return new ErrorModel
|
||||||
{
|
{
|
||||||
Message = innerException.Message,
|
Message = exception.Message,
|
||||||
Description = innerException.ToString()
|
Description = exception.ToString()
|
||||||
}.AsResponse(HttpStatusCode.InternalServerError);
|
}.AsResponse(HttpStatusCode.InternalServerError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user