コード例 #1
0
 /// <summary>
 ///  CUIアプリケーションを実行します。
 ///  例外は標準エラーストリームに出力しログファイルに保存します。
 /// </summary>
 /// <exception cref="System.AggregateException"/>
 public int Run()
 {
     try {
         this.Start();
         this.Stop();
         return(0);
     } catch (Exception e) {
         ErrorReportBuilder.PrintAndLog(e);
         return(e.HResult);
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: Takym/ExapisSOP
        private static void Config_UnhandledError(object?sender, UnhandledErrorEventArgs e)
        {
            var path = e.Context.GetLoggingSystem()?.SaveErrorReport(e.Context, e.Exception, new HResultDetailProvider());

            if (e.Context.Paths is IPathList paths)
            {
                ErrorReportBuilder.SaveERBC(paths);
            }
            var logger = e.Context.LogFile?.GetConsoleLogger();

            logger?.UnhandledException(e.Exception);
            logger?.Info("The error report file is saved to: " + path);
            e.Abort = true;
        }
コード例 #3
0
        public void SaveTest2()
        {
            var dir = PathStringPool.Get("Temp/Logs");

            Directory.CreateDirectory(dir);
            using var cts  = new CancellationTokenSource();
            using var cts2 = new CancellationTokenSource();
            cts2.Cancel();
            var ex = new AggregateException(
                new Exception(),
                new NullReferenceException(),
                new DivideByZeroException(),
                new InvalidOperationException(),
                new InvalidDataException(),
                new InvalidPathFormatException("xyz"),
                new AccessViolationException(),
                new StackOverflowException(),
                new ObjectDisposedException("a"),
                new ArgumentNullException("b"),
                new OperationCanceledException(),
                new AggregateException(
                    new Exception(),
                    new Exception(),
                    new Exception("c", new Exception("d", new Exception("e",
                                                                        new OperationCanceledException(cts.Token)
                                                                        ))),
                    new SecurityException(),
                    new SecurityException(
                        "message",
                        this.GetType(),
                        "state"
                        ),
                    new SecurityException(
                        "message",
                        new Exception()
                        )
                    ),
                new OperationCanceledException(cts2.Token),
                new OperationCanceledException(CancellationToken.None)
                );

            ErrorReportBuilder.Create(ex).Save(dir, "FULL");
        }
コード例 #4
0
 private static void SaveER(PathString dir, Exception ex)
 {
     ErrorReportBuilder.Create(ex).Save(dir, null);
 }
コード例 #5
0
 public void CreateTest()
 {
     Assert.IsTrue(ErrorReportBuilder.Create(new Exception()) is ErrorReportBuilder);
 }