Exemple #1
0
        public static void Warnings <TException>(Action <ConsolePublisher, TException> publish, IEnumerable <TException> warnings)
            where TException : Exception
        {
            var warningsList = warnings as IList <TException> ?? warnings.ToList();

            if (Verbose < 2 && !warningsList.Any())
            {
                return;
            }

            if (ReportMode == ReportMode.Release)
            {
                foreach (var warning in warningsList)
                {
                    var publisher = new ConsolePublisher();
                    publish(publisher, warning);
                    publisher.Publish(ReportSeverity.Warning);
                }
            }

            if (ReportMode == ReportMode.Debug)
            {
                ThrowExceptions(warningsList);
            }
        }
Exemple #2
0
        public static void Warning(Action <ConsolePublisher> publish)
        {
            if (Verbose < 2)
            {
                return;
            }

            var publisher = new ConsolePublisher();

            publish(publisher);
            publisher.Publish(ReportSeverity.Warning);

            if (ReportMode == ReportMode.Debug)
            {
                throw new ApplicationException("Exception from publisher.");
            }
        }
Exemple #3
0
        public static void Error <TException>(Action <ConsolePublisher> publish, TException error)
            where TException : Exception
        {
            var publisher = new ConsolePublisher();

            publish(publisher);

            if (ReportMode == ReportMode.Release)
            {
                publisher.Publish(ReportSeverity.Error);
                Environment.Exit(1);
            }

            if (ReportMode == ReportMode.Debug)
            {
                throw error;
            }
        }
Exemple #4
0
        public static void Errors <TException>(Action <ConsolePublisher, TException> publish, IEnumerable <TException> errors, bool terminate = true)
            where TException : Exception
        {
            var errorList = errors as IList <TException> ?? errors.ToList();

            if (!errorList.Any())
            {
                return;
            }

            if (ReportMode == ReportMode.Release)
            {
                foreach (var error in errorList)
                {
                    var publisher = new ConsolePublisher();
                    publish(publisher, error);
                    publisher.Publish(ReportSeverity.Error);
                }

                Environment.Exit(1);
            }

            ThrowExceptions(errorList);
        }