Exemple #1
0
        /// <summary>
        /// Assuming we have a Lua error string sitting on the stack, throw a C# exception out to the user's app
        /// </summary>
        void ThrowExceptionFromError(int oldTop)
        {
            object err = translator.getObject(luaState, -1);

            LuaDLL.lua_settop(luaState, oldTop);

            // If the 'error' on the stack is an actual C# exception, just rethrow it.  Otherwise the value must have started
            // as a true Lua error and is best interpreted as a string - wrap it in a LuaException and rethrow.
            Exception thrown = err as Exception;

            if (thrown == null)
            {
                if (err == null)
                {
                    err = "Unknown Lua Error";
                }

                thrown = new LuaException(err.ToString());
            }

            throw thrown;
        }
Exemple #2
0
        /// <summary>
        /// Assuming we have a Lua error string sitting on the stack, throw a C# exception out to the user's app
        /// </summary>
        void ThrowExceptionFromError( int oldTop )
        {
            object err = translator.getObject( luaState, -1 );
            LuaDLL.lua_settop( luaState, oldTop );

            // If the 'error' on the stack is an actual C# exception, just rethrow it.  Otherwise the value must have started
            // as a true Lua error and is best interpreted as a string - wrap it in a LuaException and rethrow.
            Exception thrown = err as Exception;

            if ( thrown == null )
            {
                if ( err == null )
                    err = "Unknown Lua Error";

                thrown = new LuaException( err.ToString() );
            }

            throw thrown;
        }