private void putLine(Channel channel, string s) // The String to print. { try { channel.write(interp, s); channel.write(interp, "\n"); channel.flush(interp); } catch (IOException ex) { System.Console.Error.WriteLine("IOException in Shell.putLine()"); SupportClass.WriteStackTrace(ex, System.Console.Error); } catch (TclException ex) { System.Console.Error.WriteLine("TclException in Shell.putLine()"); SupportClass.WriteStackTrace(ex, System.Console.Error); } }
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); } }
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(Enclosing_Instance.errors, this); // Restore important state variables to what they were at // the time the error occurred. try { Enclosing_Instance.interp.setVar("errorInfo", null, errorInfo, TCL.VarFlag.GLOBAL_ONLY); } catch (TclException e) { // Ignore any TclException's, possibly caused by variable traces on // the errorInfo variable. This is compatible with the behavior of // the Tcl C API. } try { Enclosing_Instance.interp.setVar("errorCode", null, errorCode, TCL.VarFlag.GLOBAL_ONLY); } catch (TclException e) { // Ignore any TclException's, possibly caused by variable traces on // the errorCode variable. This is compatible with the behavior of // the Tcl C API. } // Make sure, that the interpreter will surive the invocation // of the bgerror command. Enclosing_Instance.interp.preserve(); try { // Invoke the bgerror command. TclObject[] argv = new TclObject[2]; argv[0] = Enclosing_Instance.bgerrorCmdObj; argv[1] = errorMsg; Parser.evalObjv(Enclosing_Instance.interp, argv, 0, TCL.EVAL_GLOBAL); } catch (TclException e) { switch (e.getCompletionCode()) { case TCL.CompletionCode.ERROR: try { Channel chan = TclIO.getStdChannel(StdChannel.STDERR); if (Enclosing_Instance.interp.getResult().ToString().Equals("\"bgerror\" is an invalid command name or ambiguous abbreviation")) { chan.write(Enclosing_Instance.interp, errorInfo); chan.write(Enclosing_Instance.interp, "\n"); } else { chan.write(Enclosing_Instance.interp, "bgerror failed to handle background error.\n"); chan.write(Enclosing_Instance.interp, " Original error: "); chan.write(Enclosing_Instance.interp, errorMsg); chan.write(Enclosing_Instance.interp, "\n"); chan.write(Enclosing_Instance.interp, " Error in bgerror: "); chan.write(Enclosing_Instance.interp, Enclosing_Instance.interp.getResult()); chan.write(Enclosing_Instance.interp, "\n"); } chan.flush(Enclosing_Instance.interp); } catch (TclException e1) { // Ignore. } catch (System.IO.IOException e2) { // Ignore, too. } break; case TCL.CompletionCode.BREAK: for (int i = Enclosing_Instance.errors.Count - 1; i >= 0; i--) { BgError bgErr = (BgError)Enclosing_Instance.errors[i]; Enclosing_Instance.errors.RemoveAt(i); bgErr.cancel(); bgErr.errorMsg.release(); bgErr.errorMsg = null; bgErr.errorInfo.release(); bgErr.errorInfo = null; bgErr.errorCode.release(); bgErr.errorCode = null; } break; } } Enclosing_Instance.interp.release(); errorMsg.release(); errorMsg = null; errorInfo.release(); errorInfo = null; errorCode.release(); errorCode = null; }