mirror of
https://github.com/Radarr/Radarr
synced 2024-12-25 01:11:43 +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
|
@ -17,29 +17,29 @@ public ExceptionController(IDatabase database)
|
|||
{
|
||||
_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 @@ public EmptyResult ReportExisting(ExistingExceptionReport existingExceptionRepor
|
|||
|
||||
return new EmptyResult();
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult ReportNew(ExceptionReport exceptionReport)
|
||||
{
|
||||
|
@ -72,14 +72,19 @@ public JsonResult ReportNew(ExceptionReport exceptionReport)
|
|||
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 @@ private string GetExceptionDetailId(ExceptionReport exceptionReport)
|
|||
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 @@ private bool ParseErrorExists(string title)
|
|||
[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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue