-
-
Save appgurueu/a2e5378946f960c8761c03bfa60f80d4 to your computer and use it in GitHub Desktop.
Improve some error messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/script/common/c_internal.cpp b/src/script/common/c_internal.cpp | |
index b80ee6e40..ae83b8df0 100644 | |
--- a/src/script/common/c_internal.cpp | |
+++ b/src/script/common/c_internal.cpp | |
@@ -189,7 +189,7 @@ void log_deprecated(lua_State *L, std::string message, int stack_depth, bool onc | |
} | |
if (mode == DeprecatedHandlingMode::Error) | |
- script_error(L, LUA_ERRRUN, nullptr, nullptr); | |
+ throw LuaError(message); | |
else if (log) | |
infostream << script_get_backtrace(L) << std::endl; | |
} | |
diff --git a/src/script/lua_api/l_base.cpp b/src/script/lua_api/l_base.cpp | |
index 03d8ee62d..921589816 100644 | |
--- a/src/script/lua_api/l_base.cpp | |
+++ b/src/script/lua_api/l_base.cpp | |
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc., | |
#include "server.h" | |
#include <algorithm> | |
#include <cmath> | |
+#include <sstream> | |
ScriptApiBase *ModApiBase::getScriptApiBase(lua_State *L) | |
{ | |
@@ -147,11 +148,14 @@ int ModApiBase::l_deprecated_function(lua_State *L, const char *good, const char | |
== deprecated_logged.end()) { | |
deprecated_logged.emplace_back(hash); | |
- warningstream << "Call to deprecated function '" << bad << "', please use '" | |
- << good << "' at " << backtrace << std::endl; | |
+ | |
+ std::stringstream msg; | |
+ msg << "Call to deprecated function '" << bad << "', use '" << good << "' instead"; | |
+ | |
+ warningstream << msg.str() << " at " << backtrace << std::endl; | |
if (dep_mode == DeprecatedHandlingMode::Error) | |
- script_error(L, LUA_ERRRUN, NULL, NULL); | |
+ throw LuaError(msg.str()); | |
} | |
u64 end_time = porting::getTimeUs(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment