Ejemplo n.º 1
0
 private void OnError(ExceptionResultObject e)
 {
     if (e != null)
     {
         _errorMargin.Visibility = Visibility.Visible;
         _errorMargin.LineNumber = e.LineNumber;
         _errorMargin.Message    = "Exception: " + e.Message;
     }
     else
     {
         _errorMargin.Visibility = Visibility.Collapsed;
     }
 }
Ejemplo n.º 2
0
        private void DumpExceptionResultObject(ExceptionResultObject result)
        {
            lock (_lock)
            {
                using (var jsonWriter = CreateJsonWriter())
                {
                    jsonWriter.WriteStartElement("root", "");
                    jsonWriter.WriteAttributeString("type", "object");
                    jsonWriter.WriteElementString("$type", _exceptionResultTypeName);
                    jsonWriter.WriteElementString("m", result.Message);
                    jsonWriter.WriteStartElement("l");
                    jsonWriter.WriteValue(result.LineNumber);
                    jsonWriter.WriteEndElement();
                    WriteResultObjectContent(jsonWriter, result);
                    jsonWriter.WriteEndElement();
                }

                DumpNewLine();
            }
        }
Ejemplo n.º 3
0
            private Task <object> PostToExecutionThread(ScriptRunner script)
            {
                var tcs = new TaskCompletionSource <object>();

                _syncContext.Post(async o => {
                    var innerTcs = (TaskCompletionSource <object>)o;
                    try {
                        innerTcs.TrySetResult(await script.RunAsync().ConfigureAwait(false));
                    }
                    catch (FileLoadException e) when(e.InnerException is NotSupportedException)
                    {
                        Console.Error.WriteLine(e.InnerException.Message);
                        innerTcs.TrySetResult(null);
                    }
                    catch (Exception e) {
                        innerTcs.TrySetResult(ExceptionResultObject.Create(e));
                    }
                }, tcs);

                return(tcs.Task);
            }
Ejemplo n.º 4
0
 private async Task <object> ExecuteOnUIThread(ScriptRunner script)
 {
     return(await(await _serverDispatcher.InvokeAsync(
                      async() =>
     {
         try
         {
             var task = script.RunAsync();
             return await task.ConfigureAwait(false);
         }
         catch (FileLoadException e) when(e.InnerException is NotSupportedException)
         {
             Console.Error.WriteLine(e.InnerException.Message);
             return null;
         }
         catch (Exception e)
         {
             return ExceptionResultObject.Create(e);
         }
     })).ConfigureAwait(false));
 }
Ejemplo n.º 5
0
        public void DumpException(Exception exception)
        {
            if (!CanDump())
            {
                return;
            }

            try
            {
                DumpExceptionResultObject(ExceptionResultObject.Create(exception));
            }
            catch (Exception ex)
            {
                try
                {
                    DumpMessage("Error during Dump: " + ex.Message);
                }
                catch
                {
                    // ignore
                }
            }
        }
Ejemplo n.º 6
0
 private void OnError(ExceptionResultObject error) => Error?.Invoke(error);
Ejemplo n.º 7
0
 private void OnError(ExceptionResultObject e)
 {
 }