/// <summary> /// Logs error to IFormatLogger and Elmah and adds a non descriptive error message to the modelstate /// </summary> public static void Error(BaseController controller, string errorDescription) { LogAndRaiseErrorImplementation(errorDescription); if (controller.ModelState != null) controller.ModelState.AddModelError(String.Empty , string.Format("Ooops, something whent wrong. {0}. The administrator has been notified. ", errorDescription)); }
/// <summary> /// Logs error to IFormatLogger and Elmah and adds a non descriptive error message to the modelstate /// </summary> public static void Error(BaseController controller, Exception ex, string prefix, params object[] formatStringParameters) { _logger.Error(ex, prefix, formatStringParameters); ErrorSignal.FromCurrentContext().Raise(ex); string message = String.Format(prefix, formatStringParameters); string error = string.Format("Ooops, something whent wrong. {0}. The administrator has been notified. ", message); if (controller.ModelState != null) { controller.ModelState.AddModelError(String.Empty, error); } else { controller.ViewBag.Message = error; } }
private static void LogAndRaiseAuthorizationError(BaseController controller) { LogAndRaiseErrorImplementation(string.Format("Access to page '{0}' is denied for user {1})" , controller.Request.Url, controller.User.Identity.IsAuthenticated ? controller.User.Identity.Name : "?")); }