diff options
author | peterbell10 <peterbell10@live.co.uk> | 2018-09-24 22:33:39 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2018-09-24 22:33:39 +0200 |
commit | 4727ed20846bb3d1a9eabb27aaaa9c5524129556 (patch) | |
tree | d6206a51db95a15fd3dfadb9691c868fc6bd8bd1 /src/Bindings/LuaState.h | |
parent | Add BurnsInDaylight to Lua API and Monsters.ini (#4295) (diff) | |
download | cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.gz cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.bz2 cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.lz cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.xz cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.zst cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/LuaState.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 2510c6f0b..362f16e21 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -820,11 +820,29 @@ public: /** Logs all items in the current stack trace to the server console */ static void LogStackTrace(lua_State * a_LuaState, int a_StartingDepth = 0); - /** Formats and prints the message, prefixed with the current function name, then logs the stack contents and raises a Lua error. + /** Prints the message, prefixed with the current function name, then logs the stack contents and raises a Lua error. To be used for bindings when they detect bad parameters. Doesn't return, but a dummy return type is provided so that Lua API functions may do "return ApiParamError(...)". */ - int ApiParamError(const char * a_MsgFormat, fmt::ArgList); - FMT_VARIADIC(int, ApiParamError, const char *) + int ApiParamError(fmt::StringRef a_Msg); + + /** Formats and prints the message using printf-style format specifiers, but prefixed with the current function name, then logs the stack contents and raises a Lua error. + To be used for bindings when they detect bad parameters. + Doesn't return, but a dummy return type is provided so that Lua API functions may do "return ApiParamError(...)". */ + template <typename... Args> + int ApiParamError(const char * a_MsgFormat, const Args & ... a_Args) + { + return ApiParamError(Printf(a_MsgFormat, a_Args...)); + } + + /** Formats and prints the message using python-style format specifiers, but prefixed with the current function name, then logs the stack contents and raises a Lua error. + To be used for bindings when they detect bad parameters. + Doesn't return, but a dummy return type is provided so that Lua API functions may do "return ApiParamError(...)". */ + template <typename... Args> + int FApiParamError(const char * a_MsgFormat, const Args & ... a_Args) + { + return ApiParamError(fmt::format(a_MsgFormat, a_Args...)); + } + /** Returns the type of the item on the specified position in the stack */ AString GetTypeText(int a_StackPos); |