예제 #1
0
        /// <summary>
        /// Fired when an exception occurs.
        /// </summary>
        /// <param name="filterContext">The exception context.</param>
        public override void OnException(ExceptionContext filterContext)
        {
            // Get the exception
            var ex = filterContext.Exception;

            // Log it
            try
            {
                _smtpMailer.Send(_from, _to, string.Format(_subjectFormat, ex.GetType()), ex.ToString());
            }
            catch
            {
                // Exception handler CANNOT raise an exception!
            }

            // Set exception handled
            filterContext.ExceptionHandled = true;
        }
예제 #2
0
        /// <summary>
        ///     Fired when an exception occurs.
        /// </summary>
        /// <param name="filterContext">The exception context.</param>
        public override void OnException(ExceptionContext filterContext)
        {
            // Get the exception
            var ex = filterContext.Exception;

            // Log it
            try
            {
                var mailer = new SmtpMailer();
                Task.Run(async() => await mailer.Send(_from, _to, string.Format(_subjectFormat, ex.GetType()), ex.ToString())).Wait();
            }
            catch
            {
                // Exception handler CANNOT raise an exception!
            }

            // Set exception handled
            filterContext.ExceptionHandled = true;
        }