Exemplo n.º 1
0
 private void put(Channel channel, string s)
 // The String to print.
 {
     try
     {
         channel.Write(interp, s);
         channel.Flush(interp);
     }
     catch (System.IO.IOException ex)
     {
         System.Console.Error.WriteLine("IOException in Shell.put()");
         SupportClass.WriteStackTrace(ex, System.Console.Error);
     }
     catch (TclException ex)
     {
         System.Console.Error.WriteLine("TclException in Shell.put()");
         SupportClass.WriteStackTrace(ex, System.Console.Error);
     }
 }
Exemplo n.º 2
0
            public override void ProcessIdleEvent()
            {
                // During the execution of this method, elements may be removed from the errors list (because a TCL.CompletionCode.BREAK was returned by the bgerror
                // command, or because the interp was deleted). We remove this BgError instance from the list first so that this instance won't
                // be deleted twice.
                SupportClass.VectorRemoveElement(EnclosingInstance.Errors, this);
                // Restore important state variables to what they were at the time the error occurred.
                try { EnclosingInstance.Interp.SetVar("errorInfo", null, ErrorInfo, TCL.VarFlag.GLOBAL_ONLY); }
                // Ignore any TclException's, possibly caused by variable traces on the errorInfo variable. This is compatible with the behavior of the Tcl C API.
                catch (TclException) { }
                try { EnclosingInstance.Interp.SetVar("errorCode", null, ErrorCode, TCL.VarFlag.GLOBAL_ONLY); }
                // Ignore any TclException's, possibly caused by variable traces on the errorCode variable. This is compatible with the behavior of the Tcl C API.
                catch (TclException) { }
                // Make sure, that the interpreter will surive the invocation of the bgerror command.
                EnclosingInstance.Interp.preserve();
                try
                {
                    // Invoke the bgerror command.
                    TclObject[] argv = new TclObject[2];
                    argv[0] = EnclosingInstance.BgerrorCmdObj;
                    argv[1] = ErrorMsg;
                    Parser.EvalObjv(EnclosingInstance.Interp, argv, 0, TCL.EVAL_GLOBAL);
                }
                catch (TclException e)
                {
                    switch (e.GetCompletionCode())
                    {
                    case TCL.CompletionCode.ERROR:
                        try
                        {
                            Channel chan   = TclIO.GetStdChannel(StdChannel.STDERR);
                            var     interp = EnclosingInstance.Interp;
                            if (EnclosingInstance.Interp.GetResult().ToString().Equals("\"bgerror\" is an invalid command name or ambiguous abbreviation"))
                            {
                                chan.Write(interp, ErrorInfo);
                                chan.Write(interp, "\n");
                            }
                            else
                            {
                                chan.Write(interp, "bgerror failed to handle background error.\n");
                                chan.Write(interp, "    Original error: ");
                                chan.Write(interp, ErrorMsg);
                                chan.Write(interp, "\n");
                                chan.Write(interp, "    Error in bgerror: ");
                                chan.Write(interp, EnclosingInstance.Interp.GetResult());
                                chan.Write(interp, "\n");
                            }
                            chan.Flush(EnclosingInstance.Interp);
                        }
                        catch (TclException) { }    // Ignore.
                        catch (IOException) { }     // Ignore, too.
                        break;

                    case TCL.CompletionCode.BREAK:
                        for (int i = EnclosingInstance.Errors.Count - 1; i >= 0; i--)
                        {
                            BgError bgError = (BgError)EnclosingInstance.Errors[i];
                            EnclosingInstance.Errors.RemoveAt(i);
                            bgError.Cancel();
                            bgError.ErrorMsg.Release(); bgError.ErrorMsg   = null;
                            bgError.ErrorInfo.Release(); bgError.ErrorInfo = null;
                            bgError.ErrorCode.Release(); bgError.ErrorCode = null;
                        }
                        break;
                    }
                }
                EnclosingInstance.Interp.release();
                ErrorMsg.Release(); ErrorMsg   = null;
                ErrorInfo.Release(); ErrorInfo = null;
                ErrorCode.Release(); ErrorCode = null;
            }
Exemplo n.º 3
0
 private void put(Channel channel, string s)
 // The String to print.
 {
   try
   {
     channel.Write(interp, s);
     channel.Flush(interp);
   }
   catch (System.IO.IOException ex)
   {
     System.Console.Error.WriteLine("IOException in Shell.put()");
     SupportClass.WriteStackTrace(ex, System.Console.Error);
   }
   catch (TclException ex)
   {
     System.Console.Error.WriteLine("TclException in Shell.put()");
     SupportClass.WriteStackTrace(ex, System.Console.Error);
   }
 }