IsFatalException() static private méthode

static private IsFatalException ( Exception e ) : bool
e System.Exception
Résultat bool
Exemple #1
0
        private int RunCommandLine()
        {
            Debug.Assert(_engine != null);

            _commandLine = CreateCommandLine();
            ConsoleOptions consoleOptions = _languageOptionsParser.CommonConsoleOptions;

            if (consoleOptions.PrintVersionAndExit)
            {
                Console.WriteLine("{0} {1} on .NET {2}", Engine.Setup.DisplayName, Engine.LanguageVersion, typeof(String).Assembly.GetName().Version);
                return(0);
            }

            if (consoleOptions.PrintUsageAndExit)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("Usage: {0}.exe ", ExeName);
                PrintLanguageHelp(sb);
                Console.Write(sb.ToString());
                return(0);
            }

            if (_console == null)
            {
                _console = CreateConsole(Engine, _commandLine, consoleOptions);
            }

            int exitCode = 0;

            try {
                if (consoleOptions.HandleExceptions)
                {
                    try {
                        exitCode = _commandLine.Run(Engine, _console, consoleOptions);
                    } catch (Exception e) {
                        if (CommandLine.IsFatalException(e))
                        {
                            // Some exceptions are too dangerous to try to catch
                            throw;
                        }
                        UnhandledException(Engine, e);
                        exitCode = 1;
                    }
                }
                else
                {
                    exitCode = _commandLine.Run(Engine, _console, consoleOptions);
                }
            } finally {
                try {
                    Snippets.SaveAndVerifyAssemblies();
                } catch (Exception) {
                    exitCode = 1;
                }
            }

            return(exitCode);
        }
Exemple #2
0
        private int RunCommandLine()
        {
            Debug.Assert(_engine != null);

            _commandLine = CreateCommandLine();

            if (_console == null)
            {
                _console = CreateConsole(Engine, _commandLine, _consoleOptions);
            }

            int?exitCodeOverride = null;

            try {
                if (_consoleOptions.HandleExceptions)
                {
                    try {
                        _commandLine.Run(Engine, _console, _consoleOptions);
                    } catch (Exception e) {
                        if (CommandLine.IsFatalException(e))
                        {
                            // Some exceptions are too dangerous to try to catch
                            throw;
                        }
                        UnhandledException(Engine, e);
                    }
                }
                else
                {
                    _commandLine.Run(Engine, _console, _consoleOptions);
                }
            } finally {
#if FEATURE_REFEMIT
                try {
                    Snippets.SaveAndVerifyAssemblies();
                } catch (Exception) {
                    exitCodeOverride = 1;
                }
#endif
            }

            if (exitCodeOverride == null)
            {
                return(_commandLine.ExitCode);
            }
            else
            {
                return(exitCodeOverride.Value);
            }
        }
Exemple #3
0
        protected virtual int RunInteractiveLoop()
        {
            if (_scope == null)
            {
                _scope = _engine.CreateScope();
            }

#if FEATURE_REMOTING
            string remoteRuntimeChannel = _options.RemoteRuntimeChannel;
            if (remoteRuntimeChannel != null)
            {
                // Publish the ScriptScope so that the host can use it
                Remote.RemoteRuntimeServer.StartServer(remoteRuntimeChannel, _scope);
                return(0);
            }
#endif
            int?res = null;

            do
            {
                if (Options.HandleExceptions)
                {
                    try {
                        res = TryInteractiveAction();
#if !FEATURE_PROCESS
                    } catch (ExitProcessException e) {
                        res = e.ExitCode;
#endif
                    }  catch (Exception e) {
                        if (CommandLine.IsFatalException(e))
                        {
                            // Some exceptions are too dangerous to try to catch
                            throw;
                        }

                        // There should be no unhandled exceptions in the interactive session
                        // We catch all (most) exceptions here, and just display it,
                        // and keep on going
                        UnhandledException(e);
                    }
                }
                else
                {
                    res = TryInteractiveAction();
                }
            } while (res == null);

            return(res.Value);
        }