public static void Error(this IEventRegistry registry, IEventSource source, int errorClass, int errorCode, ErrorLevel level, string message, string stackTrace, string errorSource) { var errorEvent = new ErrorEvent(source, errorClass, errorCode, message); errorEvent.ErrorLevel(level); errorEvent.StackTrace(stackTrace); errorEvent.ErrorSource(errorSource); registry.RegisterEvent(errorEvent); }
public static void Error(this IEventRegistry registry, IEventSource source, Exception ex) { var errorEvent = new ErrorEvent(source, EventClasses.Runtime, -1, ex.Message); errorEvent.ErrorLevel(ErrorLevel.Error); errorEvent.StackTrace(ex.StackTrace); #if !PCL errorEvent.ErrorSource(ex.Source); #endif registry.RegisterEvent(errorEvent); }
/// <summary> /// Transforms the error to an event to be passed to the diagnostics, /// given a source where this was generated. /// </summary> /// <param name="source">The source of the error.</param> /// <returns> /// Returns an instance of <see cref="ErrorEvent"/> that encapsulates all the information /// about this exception, that can be routed to the diagnostics. /// </returns> public ErrorEvent AsEvent(IEventSource source) { var e = new ErrorEvent(source, EventClass, ErrorCode, Message); foreach (DictionaryEntry entry in Data) { e.SetData(entry.Key.ToString(), entry.Value); } e.ErrorLevel(ErrorLevel); e.StackTrace(StackTrace); #if !PCL e.ErrorSource(Source); #endif return e; }