static int __CreateInstance(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); if (LuaAPI.lua_gettop(L) == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string _message = LuaAPI.lua_tostring(L, 2); XLua.LuaException gen_ret = new XLua.LuaException(_message); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to XLua.LuaException constructor!")); }
public void ThrowExceptionFromError(int oldTop) { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif object err = translator.GetObject(L, -1); LuaAPI.lua_settop(L, oldTop); // A pre-wrapped exception - just rethrow it (stack trace of InnerException will be preserved) Exception ex = err as Exception; if (ex != null) { // 将错误日志输出到UnityEngine //UnityEngine.Debug.LogException(ex); DBOSManager.writeLuaDmpToFile(ex.Message); throw ex; } // A non-wrapped Lua error (best interpreted as a string) - wrap it and throw it if (err == null) { err = "Unknown Lua Error"; } ex = new LuaException(err.ToString()); // 将错误日志输出到UnityEngine //UnityEngine.Debug.LogException(ex); DBOSManager.writeLuaDmpToFile(ex.Message); throw ex; #if THREAD_SAFT || HOTFIX_ENABLE } #endif }