mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
added Nancy pipelines for error handling,
cleaned up container registrations.
This commit is contained in:
28
NzbDrone.Api/ErrorManagment/ErrorPipeline.cs
Normal file
28
NzbDrone.Api/ErrorManagment/ErrorPipeline.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user