public async Task <Variable> ExecuteAsync(char[] toArray = null, int from = -1) { toArray = toArray == null ? Constants.END_PARSE_ARRAY : toArray; Pointer = from < 0 ? Pointer : from; if (!m_data.EndsWith(Constants.END_STATEMENT.ToString())) { m_data += Constants.END_STATEMENT; } Variable result = null; bool handleByDebugger = DebuggerServer.DebuggerAttached && !Debugger.Executing; if (DebuggerServer.DebuggerAttached) { result = await Debugger.CheckBreakpoints(this); if (result != null) { return(result); } } if (InTryBlock) { result = await Parser.SplitAndMergeAsync(this, toArray); } else { try { result = await Parser.SplitAndMergeAsync(this, toArray); } catch (ParsingException parseExc) { if (handleByDebugger) { Debugger.ProcessException(this, parseExc); } throw; } catch (Exception exc) { ParsingException parseExc = new ParsingException(exc.Message, this, exc); if (handleByDebugger) { Debugger.ProcessException(this, parseExc); } throw parseExc; } } return(result); }
public static void ProcessException(ParsingScript script, ParsingException exc) { Debugger debugger = script != null && script.Debugger != null ? script.Debugger : MainInstance; if (debugger == null) { return; } if (debugger.ReplMode) { string replResult = DebuggerUtils.ResponseMainToken(DebuggerUtils.DebugAction.REPL) + "Exception thrown: " + exc.Message + "\n"; debugger.SendBack(replResult, false); debugger.LastResult = null; ParserFunction.InvalidateStacksAfterLevel(0); return; } string stack = exc.ExceptionStack; string vars = debugger.GetAllVariables(script); int varsCount = vars.Split('\n').Length; string result = "exc\n" + exc.Message + "\n"; //result += exc. + "\n"; result += varsCount + "\n"; result += vars + "\n"; result += stack + "\n"; debugger.SendBack(result, !debugger.ReplMode); debugger.LastResult = null; ParserFunction.InvalidateStacksAfterLevel(0); }