mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
added Nancy pipelines for error handling,
cleaned up container registrations.
This commit is contained in:
parent
acef97b79f
commit
c184595935
22 changed files with 333 additions and 201 deletions
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue