Пример #1
0
        private void FillDebugData(InterpreterException ex, int ip)
        {
            // adjust IP
            if (ip == YIELD_SPECIAL_TRAP)
            {
                ip = m_SavedInstructionPtr;
            }
            else
            {
                ip -= 1;
            }

            ex.InstructionPtr = ip;

            SourceRef sref = GetCurrentSourceRef(ip);

            if (sref != null)
            {
                ex.DecoratedMessage = string.Format("{0}: {1}", sref.FormatLocation(m_Script), ex.Message);
            }
            else
            {
                ex.DecoratedMessage = string.Format("bytecode:{0}: {1}", ip, ex.Message);
            }

            ex.CallStack = Debugger_GetCallStack(sref);
        }
Пример #2
0
        string FormatExceptionMessage(InterpreterException e)
        {
            string msg = "";

            if (e is InternalErrorException)
            {
                msg += "Internal Error ";
            }
            else if (e is SyntaxErrorException)
            {
                msg += "Syntax Error ";
            }
            else if (e is DynamicExpressionException)
            {
                msg += "Dynamic Error ";
            }
            else if (e is ScriptRuntimeException)
            {
                msg += "Runtime Error ";
            }
            else
            {
                msg += "Interpreter Error";
            }

            string error_msg = e.DecoratedMessage;
            int    pos       = error_msg.IndexOf('(');
            int    length    = error_msg.LastIndexOf(')') - pos + 1;

            msg += error_msg.Substring(pos, length) + ": ";
            msg += error_msg.Substring(error_msg.IndexOf(' '));

            return(msg);
        }
Пример #3
0
 public ParserException(InterpreterException e, string reference)
 {
     this.message     = "Error on Interpreter";
     this.reference   = reference;
     this.description = e.Message;
     this.Parse(e.DecoratedMessage);
 }
Пример #4
0
    public void ThrowExceptionToConsole(InterpreterException ex)
    {
        string niceMessage = ex.DecoratedMessage;

        niceMessage = niceMessage.Replace(@"\", "/");
        int modulesIndex = niceMessage.IndexOf("modules");

        niceMessage = niceMessage.Substring(modulesIndex, niceMessage.Length - modulesIndex);
        ConsoleController.ThrowError(niceMessage);
    }
Пример #5
0
        private void InterpreterOnLuaError(object sender, InterpreterException exception)
        {
            void MethodInvokerDelegate()
            {
                Critical($">>> {Resources.LogError}:");
                Critical($">>> {exception.DecoratedMessage}");
            }

            Invoke((MethodInvoker)MethodInvokerDelegate);
        }
Пример #6
0
    private static void Log(InterpreterException e)
    {
        string decoratedMessage = e.DecoratedMessage;

        if (string.IsNullOrEmpty(decoratedMessage))
        {
            Log((Exception)e);
            return;
        }

        string culpritFilePath = parsedFilePaths[int.Parse(decoratedMessage.Substring(6, decoratedMessage.IndexOf(":", StringComparison.Ordinal) - 6)) - 1];

        Logger.Log("Lua", string.Format("{0}\n at {1}", decoratedMessage, culpritFilePath), LoggerVerbosity.Error);
    }
Пример #7
0
        private void FillDebugData(InterpreterException ex, int ip)
        {
            // adjust IP
            if (ip == YIELD_SPECIAL_TRAP)
                ip = m_SavedInstructionPtr;
            else
                ip -= 1;

            ex.InstructionPtr = ip;

            var sref = GetCurrentSourceRef(ip);

            ex.DecorateMessage(m_Script, sref, ip);

            ex.CallStack = Debugger_GetCallStack(sref);
        }
Пример #8
0
        private void FillDebugData(InterpreterException ex, int ip)
        {
            // adjust IP
            if (ip == YIELD_SPECIAL_TRAP)
            {
                ip = _savedInstructionPtr;
            }
            else
            {
                ip -= 1;
            }

            ex.InstructionPtr = ip;

            var sref = this.GetCurrentSourceRef(ip);

            ex.DecorateMessage(_script, sref, ip);
        }
Пример #9
0
        public void EnsureSerializationOfException()
        {
            InterpreterException ex = null;

            try { throw new InterpreterException("TEST"); }
            catch (InterpreterException e) { ex = e; }

            Assert.IsNotNull(ex);
            BinaryFormatter bf = new BinaryFormatter();

            using (MemoryStream ms = new MemoryStream())
            {
                bf.Serialize(ms, ex);

                ms.Position = 0;
                ex          = (InterpreterException)bf.Deserialize(ms);
                Assert.AreEqual("TEST", ex.Message);
            }
        }
Пример #10
0
        private void FillDebugData(InterpreterException ex, int ip)
        {
            // adjust IP
            if (ip == YIELD_SPECIAL_TRAP)
            {
                ip = m_SavedInstructionPtr;
            }
            else
            {
                ip -= 1;
            }

            ex.InstructionPtr = ip;

            SourceRef sref = GetCurrentSourceRef(ip);

            ex.DecorateMessage(m_Script, sref, ip);

            ex.CallStack = Debugger_GetCallStack(sref);
        }