Пример #1
0
 public static IDisposable TryScopeCallerInfo(this Exception exception, CallerInfo info)
 {
     if (exception == null) throw new ArgumentNullException("exception");
     var previous = exception.TrySetCallerInfo(info);
     var dispose = previous != null 
                 ? (Action) (() => exception.TrySetCallerInfo(previous))
                 : (() => exception.TryClearCallerInfo());
     return new DelegatingDisposable(dispose);
 }
Пример #2
0
        public void Raise(Exception e, HttpContextBase context, CallerInfo callerInfo)
        {
            if (context == null)
                context = new HttpContextWrapper(HttpContext.Current);

            var handler = Raised;

            if (handler != null)
                handler(this, new ErrorSignalEventArgs(e, context, callerInfo));
        }
Пример #3
0
        /// <summary>
        /// Attempts to install a <see cref="CallerInfo"/> into an
        /// <see cref="Exception"/> via <see cref="Exception.Data"/>.
        /// </summary>
        /// <returns>
        /// Returns <see cref="CallerInfo"/> that was replaced otherwise
        /// <c>null</c>.
        /// </returns>

        public static CallerInfo TrySetCallerInfo(this Exception exception, CallerInfo info)
        {
            if (exception == null) throw new ArgumentNullException("exception");
            CallerInfo previous = null;
            if (exception.IsWritableData())
            {
                previous = exception.TryPopCallerInfo();
                if (info != null)
                    exception.Data[CallerInfoKey] = info;
            }
            return previous;
        }
Пример #4
0
        public ErrorSignalEventArgs(Exception e, HttpContextBase context, CallerInfo callerInfo)
        {
            if (e == null)
                throw new ArgumentNullException("e");

            _exception = e;
            _context = context;
            CallerInfo = callerInfo ?? CallerInfo.Empty;
        }