Пример #1
0
        /// <summary>
        /// Event handler raised when an exception occurs;
        /// </summary>
        /// <param name="sender">Object which raise the event.</param>
        /// <param name="eventArgs">Arguments to the event.</param>
        private static void ExceptionEventHandler(object sender, IHandleExceptionEventArgs eventArgs)
        {
            if (eventArgs == null)
            {
                throw new ArgumentNullException(nameof(eventArgs));
            }

            if (eventArgs.Exception is DeliveryEngineValidateException)
            {
                Console.WriteLine("{0}: {1}", Resource.GetText(Text.Warning), eventArgs.Message);
                InformationLogger.LogWarning(eventArgs.Message);
                AcceptWarnings       -= 1;
                eventArgs.CanContinue = ValidationOnly && (AcceptWarnings > 0);
                return;
            }

            if (eventArgs.Exception is DeliveryEngineMappingException)
            {
                Console.WriteLine("{0}: {1}", Resource.GetText(Text.Warning), eventArgs.Message);
                InformationLogger.LogWarning(eventArgs.Message);
                AcceptWarnings       -= 1;
                eventArgs.CanContinue = ValidationOnly && (AcceptWarnings > 0);
                return;
            }

            Console.WriteLine(eventArgs.Exception.Message);
            Console.WriteLine(eventArgs.Exception.StackTrace);
            Console.WriteLine();
            eventArgs.CanContinue = false;
        }
Пример #2
0
 /// <summary>
 /// Eventhandler, der kaldes, når en exception skal håndteres.
 /// </summary>
 /// <param name="sender">Objekt, der rejser eventet.</param>
 /// <param name="eventArgs">Argumenter til eventet.</param>
 private void HandleExceptionEventHandler(object sender, IHandleExceptionEventArgs eventArgs)
 {
     if (sender == null)
     {
         throw new ArgumentNullException("sender");
     }
     if (eventArgs == null)
     {
         throw new ArgumentNullException("eventArgs");
     }
     PublishEvent(eventArgs);
 }