1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Don't throw a error when writing JSON fails

This commit is contained in:
ShadowNinja 2013-12-18 18:17:26 -05:00
parent ba8fa0bd42
commit e1f9ba435f
3 changed files with 15 additions and 9 deletions

View file

@ -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) {