diff options
author | ShadowNinja <shadowninja@minetest.net> | 2013-12-18 18:17:26 -0500 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2013-12-18 18:18:43 -0500 |
commit | e1f9ba435f8c0cca90f2d3df36e9aa82763e1da0 (patch) | |
tree | e4d84dc22aff5c8048083cbfab1d7c97da958728 /src/script/lua_api | |
parent | ba8fa0bd42b5a4a0e3658a5e784ee6a885dcc891 (diff) | |
download | minetest-e1f9ba435f8c0cca90f2d3df36e9aa82763e1da0.tar.gz minetest-e1f9ba435f8c0cca90f2d3df36e9aa82763e1da0.tar.bz2 minetest-e1f9ba435f8c0cca90f2d3df36e9aa82763e1da0.zip |
Don't throw a error when writing JSON fails
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_util.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp index 9fa6fcb77..f9ec94db4 100644 --- a/src/script/lua_api/l_util.cpp +++ b/src/script/lua_api/l_util.cpp @@ -179,7 +179,7 @@ int ModApiUtil::l_parse_json(lua_State *L) return 1; } -// write_json(data[, styled]) -> string +// write_json(data[, styled]) -> string or nil and error message int ModApiUtil::l_write_json(lua_State *L) { NO_MAP_LOCK_REQUIRED; @@ -191,7 +191,13 @@ int ModApiUtil::l_write_json(lua_State *L) } Json::Value root; - get_json_value(L, root, 1); + try { + get_json_value(L, root, 1); + } catch (SerializationError &e) { + lua_pushnil(L); + lua_pushstring(L, e.what()); + return 2; + } std::string out; if (styled) { |