mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
Improve deprecation error messages
This commit is contained in:
@@ -189,7 +189,7 @@ void log_deprecated(lua_State *L, std::string message, int stack_depth, bool onc
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mode == DeprecatedHandlingMode::Error)
|
if (mode == DeprecatedHandlingMode::Error)
|
||||||
script_error(L, LUA_ERRRUN, nullptr, nullptr);
|
throw LuaError(message);
|
||||||
else if (log)
|
else if (log)
|
||||||
infostream << script_get_backtrace(L) << std::endl;
|
infostream << script_get_backtrace(L) << std::endl;
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
ScriptApiBase *ModApiBase::getScriptApiBase(lua_State *L)
|
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.end()) {
|
||||||
|
|
||||||
deprecated_logged.emplace_back(hash);
|
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)
|
if (dep_mode == DeprecatedHandlingMode::Error)
|
||||||
script_error(L, LUA_ERRRUN, NULL, NULL);
|
throw LuaError(msg.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 end_time = porting::getTimeUs();
|
u64 end_time = porting::getTimeUs();
|
||||||
|
Reference in New Issue
Block a user