public void AllExitKindsAccountedFor() { foreach (ExitKind exitKind in Enum.GetValues(typeof(ExitKind))) { // No crash = happy test ExitCode.FromExitKind(exitKind); } }
private static void HandleUnhandledFailure(Exception exception) { PrintToStderr(exception.Message ?? exception.InnerException.Message); // Log the exception to telemetry Tracing.Logger.Log.SandboxExecCrashReport(s_loggingContext, s_loggingContext.Session.ToString(), exception.ToString()); Telemetry.TelemetryShutdown(); Environment.Exit(ExitCode.FromExitKind(ExitKind.InternalError)); }
private void HandleUnhandledFailure(Exception exception) { // Show the exception to the user ConsoleColor original = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.Error.WriteLine(exception.ToString()); Console.ForegroundColor = original; // Log the exception to telemetry if (AriaV2StaticState.IsEnabled) { Tracing.Logger.Log.ExecutionAnalyzerCatastrophicFailure(LoggingContext, m_mode.ToString(), exception.ToString()); TelemetryShutdown(); } Environment.Exit(ExitCode.FromExitKind(ExitKind.InternalError)); }
/// <summary> /// The core execution of the tool. /// </summary> /// <remarks> /// If you discover boilerplate in multiple implementations, add it to MainImpl, or add another inheritance hierarchy. /// </remarks> public int Run() { // We may have been started to be an app server. See StartAppServerProcess. If so, run as an app server (and expect no args). string startupParamsSerialized = Environment.GetEnvironmentVariable(BuildXlAppServerConfigVariable); if (startupParamsSerialized != null) { if (RawArgs.Length > 0) { // TODO: Message return(ExitCode.FromExitKind(ExitKind.InvalidCommandLine)); } AppServer.StartupParameters startupParameters = AppServer.StartupParameters.TryParse(startupParamsSerialized); if (startupParameters == null) { return(ExitCode.FromExitKind(ExitKind.InvalidCommandLine)); } return(ExitCode.FromExitKind(RunAppServer(startupParameters))); } LightConfig lightConfig; if (!LightConfig.TryParse(RawArgs, out lightConfig) && lightConfig.Help == HelpLevel.None) { // If light config parsing failed, go through the full argument parser to collect & print the errors // it would catch. ICommandLineConfiguration config; Analysis.IgnoreResult(Args.TryParseArguments(RawArgs, new PathTable(), null, out config)); HelpText.DisplayHelp(BuildXL.ToolSupport.HelpLevel.Verbose); return(ExitCode.FromExitKind(ExitKind.InvalidCommandLine)); } // Not an app server; will either run fully within this process ('single instance') or start / connect to an app server. if (!lightConfig.NoLogo) { HelpText.DisplayLogo(); } if (lightConfig.Help != HelpLevel.None) { // Need to cast here to convert from the configuration enum to the ToolSupoort enum. Their values // are manually kept in sync to avoid the additional dependency. HelpText.DisplayHelp((BuildXL.ToolSupport.HelpLevel)lightConfig.Help); return(ExitCode.FromExitKind(ExitKind.BuildNotRequested)); } // Optionally perform some special tasks related to server mode switch (lightConfig.Server) { case ServerMode.Kill: ServerDeployment.KillServer(ServerDeployment.ComputeDeploymentDir(lightConfig.ServerDeploymentDirectory)); Console.WriteLine(Strings.App_ServerKilled); return(ExitCode.FromExitKind(ExitKind.BuildNotRequested)); } ExitKind exitKind = lightConfig.Server != ServerMode.Disabled ? ConnectToAppServerAndRun(lightConfig, RawArgs) : RunSingleInstance(RawArgs); return(ExitCode.FromExitKind(exitKind)); }