NzbDroneErrorPipeline uses the new aggregate exceptions.

This commit is contained in:
kay.one 2013-09-19 00:16:59 -07:00
parent 5f8c6da9d9
commit e0fb77a521
1 changed files with 11 additions and 9 deletions

View File

@ -17,9 +17,11 @@ namespace NzbDrone.Api.ErrorManagement
_logger = logger; _logger = logger;
} }
public Response HandleException(NancyContext context, Exception exception) public Response HandleException(NancyContext context, Exception aggregateException)
{ {
var apiException = exception as ApiException; var innerException = (aggregateException.InnerException).InnerException;
var apiException = innerException as ApiException;
if (apiException != null) if (apiException != null)
{ {
@ -27,7 +29,7 @@ namespace NzbDrone.Api.ErrorManagement
return apiException.ToErrorResponse(); return apiException.ToErrorResponse();
} }
var validationException = exception as ValidationException; var validationException = innerException as ValidationException;
if (validationException != null) if (validationException != null)
{ {
@ -36,23 +38,23 @@ namespace NzbDrone.Api.ErrorManagement
return validationException.Errors.AsResponse(HttpStatusCode.BadRequest); return validationException.Errors.AsResponse(HttpStatusCode.BadRequest);
} }
var clientException = exception as NzbDroneClientException; var clientException = innerException as NzbDroneClientException;
if (clientException != null) if (clientException != null)
{ {
return new ErrorModel return new ErrorModel
{ {
Message = exception.Message, Message = innerException.Message,
Description = exception.ToString() Description = innerException.ToString()
}.AsResponse((HttpStatusCode)clientException.StatusCode); }.AsResponse((HttpStatusCode)clientException.StatusCode);
} }
_logger.FatalException("Request Failed", exception); _logger.FatalException("Request Failed", innerException);
return new ErrorModel return new ErrorModel
{ {
Message = exception.Message, Message = innerException.Message,
Description = exception.ToString() Description = innerException.ToString()
}.AsResponse(HttpStatusCode.InternalServerError); }.AsResponse(HttpStatusCode.InternalServerError);
} }
} }