コード例 #1
0
        }         // func GetDebugInfo

        /// <summary>Executes the Chunk on the given Environment</summary>
        /// <param name="env"></param>
        /// <param name="callArgs"></param>
        /// <returns></returns>
        public LuaResult Run(LuaTable env, params object[] callArgs)
        {
            if (!IsCompiled)
            {
                throw new ArgumentException(Properties.Resources.rsChunkNotCompiled, "chunk");
            }

            object[] args = new object[callArgs == null ? 0 : callArgs.Length + 1];
            args[0] = env;
            if (callArgs != null)
            {
                Array.Copy(callArgs, 0, args, 1, callArgs.Length);
            }

            try
            {
                object r = chunk.DynamicInvoke(args);
                return(r is LuaResult ? (LuaResult)r : new LuaResult(r));
            }
            catch (TargetInvocationException e)
            {
                LuaExceptionData.GetData(e.InnerException); // secure the stacktrace
                throw e.InnerException;                     // rethrow with new stackstrace
            }
        }                                                   // proc Run
コード例 #2
0
ファイル: Exceptions.cs プロジェクト: xiuzhifu/neolua
        }         // func GetStackTrace

        /// <summary>Retrieves the debug information for an exception.</summary>
        /// <param name="ex">Exception</param>
        /// <returns>Debug Information</returns>
        public static LuaExceptionData GetData(Exception ex)
        {
            LuaExceptionData data = ex.Data[luaStackTraceDataKey] as LuaExceptionData;

            if (data == null)
            {
                // retrieve the stacktrace
                data = new LuaExceptionData(GetStackTrace(new StackTrace(ex, true)));

                // set the data
                ex.Data[luaStackTraceDataKey] = data;
            }
            return(data);
        } // func GetData
コード例 #3
0
ファイル: Program.cs プロジェクト: weimingtom/neolua
        } // proc WriteError

        private static void WriteException(Exception e)
        {
            WriteText(ConsoleColor.DarkRed, e.GetType().Name + ": ");
            WriteText(ConsoleColor.Red, e.Message);
            Console.WriteLine();
            LuaExceptionData eData = LuaExceptionData.GetData(e);

            WriteText(ConsoleColor.DarkGray, eData.FormatStackTrace(0, true));
            Console.WriteLine();
            if (e.InnerException != null)
            {
                WriteText(ConsoleColor.Gray, ">>> INNER EXCEPTION <<<");
                WriteException(e.InnerException);
            }
        } // proc WriteException
コード例 #4
0
ファイル: Exceptions.cs プロジェクト: edisonh/neolua
        }         // func GetStackTrace

        /// <summary>Retrieves the debug information for an exception.</summary>
        /// <param name="ex">Exception</param>
        /// <param name="resolveStackTrace"></param>
        /// <returns>Debug Information</returns>
        public static LuaExceptionData GetData(Exception ex, bool resolveStackTrace = true)
        {
            var data = ex.Data[LuaRuntimeException.ExceptionDataKey] as LuaExceptionData;

            if (data == null)
            {
                // retrieve the stacktrace
                data = new LuaExceptionData(
                    resolveStackTrace ?
                    GetStackTrace(new StackTrace(ex, true)) :
                    new LuaStackFrame[0]
                    );

                // set the data
                ex.Data[LuaRuntimeException.ExceptionDataKey] = data;
            }
            return(data);
        } // func GetData
コード例 #5
0
            }             // ctor

            public void UnwindException(Exception e, string fileName, int lineNumber)
            => LuaExceptionData.UnwindException(e, () => new LuaExceptionLineInfo(this, fileName, lineNumber));