mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-03-20 20:37:33 +00:00
Reportingare.ReportException are now routed to ExceptionController
This commit is contained in:
@@ -17,29 +17,29 @@ namespace NzbDrone.Services.Service.Controllers
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public EmptyResult ReportExisting(ExistingExceptionReport existingExceptionReport)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ExceptionHashExists(existingExceptionReport.Hash))
|
||||
{
|
||||
if (ExceptionHashExists(existingExceptionReport.Hash))
|
||||
{
|
||||
|
||||
var exceptionInstance = new ExceptionInstance
|
||||
{
|
||||
ExceptionHash = existingExceptionReport.Hash,
|
||||
IsProduction = existingExceptionReport.IsProduction,
|
||||
LogMessage = existingExceptionReport.LogMessage,
|
||||
Timestamp = DateTime.Now
|
||||
};
|
||||
var exceptionInstance = new ExceptionInstance
|
||||
{
|
||||
ExceptionHash = existingExceptionReport.Hash,
|
||||
IsProduction = existingExceptionReport.IsProduction,
|
||||
LogMessage = existingExceptionReport.LogMessage,
|
||||
Timestamp = DateTime.Now
|
||||
};
|
||||
|
||||
_database.Insert(exceptionInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Warn("Invalid exception hash '{0}'", existingExceptionReport.Hash);
|
||||
}
|
||||
_database.Insert(exceptionInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Warn("Invalid exception hash '{0}'", existingExceptionReport.Hash);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ namespace NzbDrone.Services.Service.Controllers
|
||||
|
||||
return new EmptyResult();
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult ReportNew(ExceptionReport exceptionReport)
|
||||
{
|
||||
@@ -72,14 +72,19 @@ namespace NzbDrone.Services.Service.Controllers
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.FatalException("Error has occurred while saving exception", e);
|
||||
throw;
|
||||
if (!exceptionReport.IsProduction)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return new JsonResult();
|
||||
}
|
||||
|
||||
|
||||
private string GetExceptionDetailId(ExceptionReport exceptionReport)
|
||||
{
|
||||
var reportHash = Hash(String.Concat(exceptionReport.Version, exceptionReport.String, exceptionReport.Logger));
|
||||
|
||||
|
||||
if (!ExceptionHashExists(reportHash))
|
||||
{
|
||||
var exeptionDetail = new ExceptionDetail();
|
||||
@@ -89,7 +94,7 @@ namespace NzbDrone.Services.Service.Controllers
|
||||
exeptionDetail.Type = exceptionReport.Type;
|
||||
exeptionDetail.Version = exceptionReport.Version;
|
||||
|
||||
_database.Insert(exeptionDetail);
|
||||
_database.Insert(exeptionDetail);
|
||||
}
|
||||
|
||||
return reportHash;
|
||||
|
||||
@@ -13,30 +13,47 @@ namespace NzbDrone.Services.Service.Controllers
|
||||
public class ReportingController : Controller
|
||||
{
|
||||
private readonly IDatabase _database;
|
||||
private readonly ExceptionController _exceptionController;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private const string OK = "OK";
|
||||
|
||||
public ReportingController(IDatabase database)
|
||||
public ReportingController(IDatabase database, ExceptionController exceptionController)
|
||||
{
|
||||
_database = database;
|
||||
_exceptionController = exceptionController;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult ParseError(ParseErrorReport parseErrorReport)
|
||||
{
|
||||
logger.Trace(parseErrorReport.NullSafe());
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
logger.Trace(parseErrorReport.NullSafe());
|
||||
|
||||
if (ParseErrorExists(parseErrorReport.Title))
|
||||
return Json(OK);
|
||||
|
||||
var row = new ParseErrorRow();
|
||||
row.LoadBase(parseErrorReport);
|
||||
row.Title = parseErrorReport.Title;
|
||||
|
||||
_database.Insert(row);
|
||||
|
||||
if (ParseErrorExists(parseErrorReport.Title))
|
||||
return Json(OK);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.FatalException("Error has occurred while saving parse report", e);
|
||||
if (!parseErrorReport.IsProduction)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
var row = new ParseErrorRow();
|
||||
row.LoadBase(parseErrorReport);
|
||||
row.Title = parseErrorReport.Title;
|
||||
|
||||
_database.Insert(row);
|
||||
|
||||
return Json(OK);
|
||||
return new JsonResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,25 +65,7 @@ namespace NzbDrone.Services.Service.Controllers
|
||||
[HttpPost]
|
||||
public JsonResult ReportException(ExceptionReport exceptionReport)
|
||||
{
|
||||
try
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
return _exceptionController.ReportNew(exceptionReport);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user