Reportingare.ReportException are now routed to ExceptionController

pull/2/head
kay.one 13 years ago
parent c5d2ba9bef
commit b2cce4d4f0

@ -23,23 +23,23 @@ namespace NzbDrone.Services.Service.Controllers
{ {
try try
{ {
if (ExceptionHashExists(existingExceptionReport.Hash)) if (ExceptionHashExists(existingExceptionReport.Hash))
{ {
var exceptionInstance = new ExceptionInstance var exceptionInstance = new ExceptionInstance
{ {
ExceptionHash = existingExceptionReport.Hash, ExceptionHash = existingExceptionReport.Hash,
IsProduction = existingExceptionReport.IsProduction, IsProduction = existingExceptionReport.IsProduction,
LogMessage = existingExceptionReport.LogMessage, LogMessage = existingExceptionReport.LogMessage,
Timestamp = DateTime.Now Timestamp = DateTime.Now
}; };
_database.Insert(exceptionInstance); _database.Insert(exceptionInstance);
} }
else else
{ {
logger.Warn("Invalid exception hash '{0}'", existingExceptionReport.Hash); logger.Warn("Invalid exception hash '{0}'", existingExceptionReport.Hash);
} }
} }
catch (Exception e) catch (Exception e)
{ {
@ -72,8 +72,13 @@ 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);
throw; if (!exceptionReport.IsProduction)
{
throw;
}
} }
return new JsonResult();
} }
private string GetExceptionDetailId(ExceptionReport exceptionReport) private string GetExceptionDetailId(ExceptionReport exceptionReport)
@ -89,7 +94,7 @@ namespace NzbDrone.Services.Service.Controllers
exeptionDetail.Type = exceptionReport.Type; exeptionDetail.Type = exceptionReport.Type;
exeptionDetail.Version = exceptionReport.Version; exeptionDetail.Version = exceptionReport.Version;
_database.Insert(exeptionDetail); _database.Insert(exeptionDetail);
} }
return reportHash; return reportHash;

@ -13,30 +13,47 @@ 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)
{ {
logger.Trace(parseErrorReport.NullSafe()); try
{
if (ParseErrorExists(parseErrorReport.Title))
return Json(OK);
var row = new ParseErrorRow(); logger.Trace(parseErrorReport.NullSafe());
row.LoadBase(parseErrorReport);
row.Title = parseErrorReport.Title;
_database.Insert(row); if (ParseErrorExists(parseErrorReport.Title))
return Json(OK);
var row = new ParseErrorRow();
row.LoadBase(parseErrorReport);
row.Title = parseErrorReport.Title;
_database.Insert(row);
return Json(OK);
}
catch (Exception e)
{
logger.FatalException("Error has occurred while saving parse report", e);
if (!parseErrorReport.IsProduction)
{
throw;
}
}
return Json(OK); return new JsonResult();
} }
@ -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…
Cancel
Save