コード例 #1
0
ファイル: BlogErrorAttribute.cs プロジェクト: LByron/BS
        /// <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);
        }
コード例 #2
0
ファイル: Global.asax.cs プロジェクト: LByron/BS
 private void Log(Exception exception)
 {
     var errorLogger = new ErrorLogger(exception);
     errorLogger.Log();
 }