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); }
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)); }
/// <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; }
public ErrorSignalEventArgs(Exception e, HttpContextBase context, CallerInfo callerInfo) { if (e == null) throw new ArgumentNullException("e"); _exception = e; _context = context; CallerInfo = callerInfo ?? CallerInfo.Empty; }