Inheritance: Controller
Example #1
0
 /// <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));
 }
Example #2
0
        /// <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;
            }
        }
Example #3
0
 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 : "?"));
 }