mirror of
https://github.com/Sonarr/Sonarr
synced 2025-03-10 14:15:29 +00:00
Reportingare.ReportException are now routed to ExceptionController
This commit is contained in:
parent
c5d2ba9bef
commit
b2cce4d4f0
2 changed files with 54 additions and 50 deletions
|
@ -72,10 +72,15 @@ namespace NzbDrone.Services.Service.Controllers
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.FatalException("Error has occurred while saving exception", e);
|
logger.FatalException("Error has occurred while saving exception", e);
|
||||||
|
if (!exceptionReport.IsProduction)
|
||||||
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new JsonResult();
|
||||||
|
}
|
||||||
|
|
||||||
private string GetExceptionDetailId(ExceptionReport exceptionReport)
|
private string GetExceptionDetailId(ExceptionReport exceptionReport)
|
||||||
{
|
{
|
||||||
var reportHash = Hash(String.Concat(exceptionReport.Version, exceptionReport.String, exceptionReport.Logger));
|
var reportHash = Hash(String.Concat(exceptionReport.Version, exceptionReport.String, exceptionReport.Logger));
|
||||||
|
|
|
@ -13,18 +13,24 @@ namespace NzbDrone.Services.Service.Controllers
|
||||||
public class ReportingController : Controller
|
public class ReportingController : Controller
|
||||||
{
|
{
|
||||||
private readonly IDatabase _database;
|
private readonly IDatabase _database;
|
||||||
|
private readonly ExceptionController _exceptionController;
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private const string OK = "OK";
|
private const string OK = "OK";
|
||||||
|
|
||||||
public ReportingController(IDatabase database)
|
public ReportingController(IDatabase database, ExceptionController exceptionController)
|
||||||
{
|
{
|
||||||
_database = database;
|
_database = database;
|
||||||
|
_exceptionController = exceptionController;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public JsonResult ParseError(ParseErrorReport parseErrorReport)
|
public JsonResult ParseError(ParseErrorReport parseErrorReport)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
logger.Trace(parseErrorReport.NullSafe());
|
logger.Trace(parseErrorReport.NullSafe());
|
||||||
|
|
||||||
if (ParseErrorExists(parseErrorReport.Title))
|
if (ParseErrorExists(parseErrorReport.Title))
|
||||||
|
@ -38,6 +44,17 @@ namespace NzbDrone.Services.Service.Controllers
|
||||||
|
|
||||||
return Json(OK);
|
return Json(OK);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logger.FatalException("Error has occurred while saving parse report", e);
|
||||||
|
if (!parseErrorReport.IsProduction)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new JsonResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private bool ParseErrorExists(string title)
|
private bool ParseErrorExists(string title)
|
||||||
|
@ -48,25 +65,7 @@ namespace NzbDrone.Services.Service.Controllers
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public JsonResult ReportException(ExceptionReport exceptionReport)
|
public JsonResult ReportException(ExceptionReport exceptionReport)
|
||||||
{
|
{
|
||||||
try
|
return _exceptionController.ReportNew(exceptionReport);
|
||||||
{
|
|
||||||
var row = new ExceptionRow();
|
|
||||||
row.LoadBase(exceptionReport);
|
|
||||||
row.LogMessage = exceptionReport.LogMessage;
|
|
||||||
row.Logger = exceptionReport.Logger;
|
|
||||||
row.String = exceptionReport.String;
|
|
||||||
row.Type = exceptionReport.Type;
|
|
||||||
|
|
||||||
_database.Insert(row);
|
|
||||||
|
|
||||||
return Json(OK);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
logger.Trace(exceptionReport.NullSafe());
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue