static async Task <int> RunOptionsAndReturnExitCodeAsync(Options opts) { // N.B. The aggregation process re-aggregates all the data from scratch. LoggingDataLayer logging_repo = new LoggingDataLayer(); Aggregator ag = new Aggregator(logging_repo); logging_repo.OpenLogFile(opts); try { await ag.AggregateDataAsync(opts); return(0); } catch (Exception e) { logging_repo.LogError("Unhandled exception: " + e.Message); logging_repo.LogLine(e.StackTrace); logging_repo.LogLine(e.TargetSite.Name); logging_repo.CloseLog(); return(-1); } }