Exemplo n.º 1
0
        /// <summary>
        /// Called when an exception occurs.
        /// 
        /// Depending on the type of exception, user is redirected to a corresponding page
        /// 
        ///     * UrlNotFoundException -> 404 page
        ///     * Any other exception -> a generic error page
        /// </summary>
        /// <param name="filterContext">The action-filter context.</param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="filterContext"/> parameter is null.</exception>
        public override void OnException(ExceptionContext filterContext)
        {
            var errType = string.Empty;
            var exception = filterContext.Exception;

            var errorLogger = new ErrorLogger(exception);
            errorLogger.Log();

            filterContext.ExceptionHandled = true;
            filterContext.Result = GetRedirectResultByExceptionType(errType, filterContext);

            base.OnException(filterContext);
        }
Exemplo n.º 2
0
 private void Log(Exception exception)
 {
     var errorLogger = new ErrorLogger(exception);
     errorLogger.Log();
 }