|
|
@ -24,26 +24,20 @@ namespace Lidarr.Http.ErrorManagement
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Trace("Handling Exception");
|
|
|
|
_logger.Trace("Handling Exception");
|
|
|
|
|
|
|
|
|
|
|
|
var apiException = exception as ApiException;
|
|
|
|
if (exception is ApiException apiException)
|
|
|
|
|
|
|
|
|
|
|
|
if (apiException != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Warn(apiException, "API Error");
|
|
|
|
_logger.Warn(apiException, "API Error");
|
|
|
|
return apiException.ToErrorResponse(context);
|
|
|
|
return apiException.ToErrorResponse(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var validationException = exception as ValidationException;
|
|
|
|
if (exception is ValidationException validationException)
|
|
|
|
|
|
|
|
|
|
|
|
if (validationException != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Warn("Invalid request {0}", validationException.Message);
|
|
|
|
_logger.Warn("Invalid request {0}", validationException.Message);
|
|
|
|
|
|
|
|
|
|
|
|
return validationException.Errors.AsResponse(context, HttpStatusCode.BadRequest);
|
|
|
|
return validationException.Errors.AsResponse(context, HttpStatusCode.BadRequest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var clientException = exception as NzbDroneClientException;
|
|
|
|
if (exception is NzbDroneClientException clientException)
|
|
|
|
|
|
|
|
|
|
|
|
if (clientException != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return new ErrorModel
|
|
|
|
return new ErrorModel
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -52,9 +46,25 @@ namespace Lidarr.Http.ErrorManagement
|
|
|
|
}.AsResponse(context, (HttpStatusCode)clientException.StatusCode);
|
|
|
|
}.AsResponse(context, (HttpStatusCode)clientException.StatusCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var sqLiteException = exception as SQLiteException;
|
|
|
|
if (exception is ModelNotFoundException notFoundException)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return new ErrorModel
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Message = exception.Message,
|
|
|
|
|
|
|
|
Description = exception.ToString()
|
|
|
|
|
|
|
|
}.AsResponse(context, HttpStatusCode.NotFound);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (exception is ModelConflictException conflictException)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return new ErrorModel
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Message = exception.Message,
|
|
|
|
|
|
|
|
Description = exception.ToString()
|
|
|
|
|
|
|
|
}.AsResponse(context, HttpStatusCode.Conflict);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (sqLiteException != null)
|
|
|
|
if (exception is SQLiteException sqLiteException)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (context.Request.Method == "PUT" || context.Request.Method == "POST")
|
|
|
|
if (context.Request.Method == "PUT" || context.Request.Method == "POST")
|
|
|
|
{
|
|
|
|
{
|
|
|
|