Add logging
This commit is contained in:
@@ -1,18 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using InventoryTraker.Web.ActionResults;
|
||||
using InventoryTraker.Web.Utilities;
|
||||
using NLog;
|
||||
|
||||
namespace InventoryTraker.Web.Controllers
|
||||
{
|
||||
public abstract class ControllerBase : Controller
|
||||
{
|
||||
public BetterJsonResult<T> BetterJson<T>(T model)
|
||||
protected override void OnException(ExceptionContext ctx)
|
||||
{
|
||||
if (ctx?.Exception != null)
|
||||
{
|
||||
var loggerName = ctx.GetLoggerName();
|
||||
|
||||
LogManager.GetLogger(loggerName).Error(ctx.Exception);
|
||||
}
|
||||
|
||||
base.OnException(ctx);
|
||||
}
|
||||
|
||||
protected BetterJsonResult<T> BetterJson<T>(T model)
|
||||
{
|
||||
return new BetterJsonResult<T> {Data = model};
|
||||
}
|
||||
|
||||
protected string[] GetModelStateErrorList()
|
||||
private string[] GetModelStateErrorList()
|
||||
{
|
||||
var errorList =
|
||||
from kvp in ModelState
|
||||
|
||||
Reference in New Issue
Block a user