public static void AddDetailedModelExceptionIfUserIsInRole(this ModelStateDictionary modelState, string key, Exception e, string role) { if (HttpContext.Current?.User?.IsInRole(role) == true) { modelState.AddDetailedModelException(key, e); } }