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); } }
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."); } }
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; } }
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); }