﻿using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;

namespace Umbraco.Web.WebApi
{
    /// <summary>
    /// Ensures controllers have detailed error messages even when debug mode is off
    /// </summary>
    public class EnableDetailedErrorsAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
        }
    }
}

﻿using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;

namespace Umbraco.Web.WebApi
{
    /// <summary>
    /// Ensures controllers have detailed error messages even when debug mode is off
    /// </summary>
    public class EnableDetailedErrorsAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = HttpContext.Current.IsDebuggingEnabled ? IncludeErrorDetailPolicy.Always : IncludeErrorDetailPolicy.Default;
        }
    }
}

Check if we're in debug and set IncludeErrorPolicy accordingly
Check if we're in debug and set IncludeErrorPolicy accordingly
