Exemple #1
0
        /// <summary>
        /// Displays an error
        /// </summary>
        /// <param name="targetElementId">HTML id to put error information into</param>
        /// <param name="e">Exception to get error info out of</param>
        internal static void DisplayError(string targetElementId, Exception e)
        {
            // we only support displaying one error
            if (_displayedError)
            {
                return;
            }
            _displayedError = true;

            // keep track of the runtime if it exists
            if (DynamicApplication.Current.Engine != null)
            {
                _runtime = DynamicApplication.Current.Engine.Runtime;
            }

            // show the window in the targetElementId
            Window.Show(targetElementId);

            // show the Repl if we can get to the current engine
            if (DynamicApplication.Current.Engine != null)
            {
                Repl.Show();
            }

            // format the Exception
            string result;

            try {
                result = FormatErrorAsHtml(e);
            } catch (Exception ex) {
                result = EscapeHtml(ex.ToString());
            }

            // Create a "div" with class/id set as the _errorReportId, and put
            // formatted exception into it.
            var report = HtmlPage.Document.CreateElement("div");

            report.Id = report.CssClass = _errorReportId;
            report.SetProperty("innerHTML", result);

            // Adds a new panel to the "Window", initialize it, and force the panel to be shown.
            Window.Current.AddPanel("Error Report (" + EscapeHtml(new DynamicExceptionInfo(e).ErrorTypeName) + ")", report);
            Window.Current.Initialize();
            Window.Current.ShowPanel(report.Id);
        }
Exemple #2
0
 /// <summary>
 /// Starts the dynamic application
 /// </summary>
 void DynamicApplication_Startup(object sender, StartupEventArgs e)
 {
     Settings.Parse(InitParams = NormalizeInitParams(e.InitParams));
     ScriptTags = new DynamicScriptTags(LanguagesConfig);
     XamlScriptTags.Load();
     LanguagesConfig.DownloadLanguages(AppManifest, () => {
         ScriptTags.DownloadExternalCode(() => {
             Engine = new DynamicEngine();
             if (Settings.ConsoleEnabled && LanguagesConfig.LanguagesUsed.Count > 0)
             {
                 Console = Repl.Show();
             }
             LanguageTypeExtensions.Load(Engine.LangConfig);
             ScriptTags.Run(Engine);
             Engine.Run(Settings.EntryPoint);
         });
     });
 }