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(errorClass, errorCode, message);
            errorEvent.ErrorLevel(level);
            errorEvent.StackTrace(stackTrace);
            errorEvent.ErrorSource(errorSource);

            if (source != null)
                source.AppendEventData(errorEvent);

            registry.RegisterEvent(errorEvent);
        }
        public static void Error(this IEventRegistry registry, IEventSource source, Exception ex)
        {
            var errorEvent = new ErrorEvent(EventClasses.Runtime, -1, ex.Message);
            errorEvent.ErrorLevel(ErrorLevel.Error);
            errorEvent.StackTrace(ex.StackTrace);
            #if !PCL
            errorEvent.ErrorSource(ex.Source);
            #endif

            if (source != null)
                source.AppendEventData(errorEvent);

            registry.RegisterEvent(errorEvent);
        }
Esempio n. 3
0
        /// <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(EventClass, ErrorCode, Message);

            foreach (DictionaryEntry entry in Data) {
                e.SetData(entry.Key.ToString(), entry.Value);
            }

            if (source != null)
                source.AppendEventData(e);

            e.ErrorLevel(ErrorLevel);
            e.StackTrace(StackTrace);
            #if !PCL
            e.ErrorSource(Source);
            #endif

            return e;
        }