Пример #1
0
        /// <summary>
        /// Ship an exception to elmah.io manually:
        /// <code>ex.Ship(HttpContext);</code>
        /// </summary>
        /// <param name="exception"></param>
        /// <param name="context"></param>
        public static void Ship(this Exception exception, HttpContext context)
        {
            var options = (IOptions <ElmahIoOptions>)context.RequestServices.GetService(typeof(IOptions <ElmahIoOptions>));
            var queue   = (IBackgroundTaskQueue)context.RequestServices.GetService(typeof(IBackgroundTaskQueue));

            MessageShipper.Ship(exception, exception.GetBaseException().Message, context, options.Value, queue);
        }
Пример #2
0
        public async Task Invoke(HttpContext context)
        {
            try
            {
                await _next.Invoke(context);

                if (ShoudLogStatusCode(context))
                {
                    MessageShipper.Ship(null, "Unsuccessful status code in response", context, _options, _queue);
                }
            }
            catch (Exception exception)
            {
                MessageShipper.Ship(exception, exception.GetBaseException().Message, context, _options, _queue);
                throw;
            }
        }