From 281f8feabffd69928a0a0f08aa31f70b36f5e6bd Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 3 Nov 2018 21:11:41 +0800 Subject: =?UTF-8?q?*=E5=A2=9E=E5=8A=A0=E6=B8=B8=E6=88=8F=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/modules/audio/je_lua_audio.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/lua/modules/audio/je_lua_audio.cpp') diff --git a/src/lua/modules/audio/je_lua_audio.cpp b/src/lua/modules/audio/je_lua_audio.cpp index 0f2f713..698d88a 100644 --- a/src/lua/modules/audio/je_lua_audio.cpp +++ b/src/lua/modules/audio/je_lua_audio.cpp @@ -78,28 +78,28 @@ namespace JinEngine AssetDatabase* fs = AssetDatabase::get(); const char* f = luax_checkstring(L, 1); Buffer b; - if (!fs->exists(f)) + try { - error(L, "No such image %s", f); - goto fail; + if (!fs->exists(f)) + throw Exception("No such source file %s.", f); + fs->read(f, b); } - if (!fs->read(f, b)) + catch (Exception& e) { error(L, "Failed to read source file %s", f); - goto fail; + luax_pushnil(L); + return 1; } Source* src = Source::createSource((void*)&b, b.size()); if (src == nullptr) { error(L, "Failed to decode source file %s", f); - goto fail; + luax_pushnil(L); + return 1; } Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_AUDIO_SOURCE, sizeof(Proxy)); proxy->bind(new Ref(src, JIN_AUDIO_SOURCE)); return 1; - fail: - luax_pushnil(L); - return 1; } LUA_IMPLEMENT int l_destroy(lua_State* L) -- cgit v1.1-26-g67d0