diff options
author | Mattes D <github@xoft.cz> | 2023-05-11 22:05:17 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2023-05-16 23:50:37 +0200 |
commit | c9522fb740200ccef6230cec452c48efb31e5394 (patch) | |
tree | 7e74d70699e13dd0a92444a1a0add7a3059ac7ca /src/Bindings/ManualBindings_Network.cpp | |
parent | Try a timeout for jobs. (diff) | |
download | cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.gz cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.bz2 cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.lz cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.xz cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.zst cuberite-c9522fb740200ccef6230cec452c48efb31e5394.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/ManualBindings_Network.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/Bindings/ManualBindings_Network.cpp b/src/Bindings/ManualBindings_Network.cpp index 911e1a8bb..67385cce6 100644 --- a/src/Bindings/ManualBindings_Network.cpp +++ b/src/Bindings/ManualBindings_Network.cpp @@ -51,7 +51,7 @@ static int tolua_cNetwork_Connect(lua_State * L) // Check validity: if ((port < 0) || (port > 65535)) { - return S.ApiParamError("Port number out of range (%d, range 0 - 65535)", port); + return S.ApiParamError(fmt::format(FMT_STRING("Port number out of range (got {}, range 0 - 65535)"), port)); } ASSERT(callbacks != nullptr); // Invalid callbacks would have resulted in GetStackValues() returning false @@ -97,7 +97,7 @@ static int tolua_cNetwork_CreateUDPEndpoint(lua_State * L) // Check validity: if ((port < 0) || (port > 65535)) { - return S.ApiParamError("Port number out of range (%d, range 0 - 65535)", port); + return S.ApiParamError(fmt::format(FMT_STRING("Port number out of range (got {}, range 0 - 65535)"), port)); } ASSERT(callbacks != nullptr); // Invalid callbacks would have resulted in GetStackValues() returning false @@ -242,7 +242,7 @@ static int tolua_cNetwork_Listen(lua_State * L) // Check the validity: if ((port < 0) || (port > 65535)) { - return S.ApiParamError("Port number out of range (%d, range 0 - 65535)", port); + return S.ApiParamError(fmt::format(FMT_STRING("Port number out of range (got {}, range 0 - 65535)"), port)); } auto port16 = static_cast<UInt16>(port); @@ -565,7 +565,10 @@ static int tolua_cTCPLink_StartTLSClient(lua_State * L) AString res = Link->StartTLSClient(OwnCert, OwnPrivKey, OwnPrivKeyPassword); if (!res.empty()) { - S.Push(cLuaState::Nil, Printf("Cannot start TLS on link to %s:%d: %s", Link->GetRemoteIP().c_str(), Link->GetRemotePort(), res.c_str())); + S.Push(cLuaState::Nil, fmt::format( + FMT_STRING("Cannot start TLS on link to {}:{}: {}"), + Link->GetRemoteIP(), Link->GetRemotePort(), res + )); return 2; } return 1; @@ -604,7 +607,10 @@ static int tolua_cTCPLink_StartTLSServer(lua_State * L) AString res = Link->StartTLSServer(OwnCert, OwnPrivKey, OwnPrivKeyPassword, StartTLSData); if (!res.empty()) { - S.Push(cLuaState::Nil, Printf("Cannot start TLS on link to %s:%d: %s", Link->GetRemoteIP().c_str(), Link->GetRemotePort(), res.c_str())); + S.Push(cLuaState::Nil, fmt::format( + FMT_STRING("Cannot start TLS on link to {}:{}: {}"), + Link->GetRemoteIP(), Link->GetRemotePort(), res + )); return 2; } S.Push(true); @@ -773,7 +779,7 @@ static int tolua_cUDPEndpoint_Send(lua_State * L) // Check the port: if ((remotePort < 0) || (remotePort > USHRT_MAX)) { - return S.ApiParamError("Port number out of range (%d, range 0 - 65535)", remotePort); + return S.ApiParamError(fmt::format(FMT_STRING("Port number out of range (got {}, range 0 - 65535)"), remotePort)); } // Send the data: @@ -958,14 +964,14 @@ static int tolua_cUrlClient_Request_Common(lua_State * a_LuaState, const AString cLuaState::cCallbackPtr onCompleteBodyCallback; if (!L.GetStackValues(a_UrlStackIdx, url)) { - return L.ApiParamError("Cannot read URL parameter at idx %d", a_UrlStackIdx); + return L.ApiParamError(fmt::format(FMT_STRING("Cannot read URL parameter at idx {}"), a_UrlStackIdx)); } cUrlClient::cCallbacksPtr urlClientCallbacks; if (lua_istable(L, a_UrlStackIdx + 1)) { if (!L.GetStackValue(a_UrlStackIdx + 1, callbacks)) { - return L.ApiParamError("Cannot read the CallbacksTable parameter at idx %d", a_UrlStackIdx + 1); + return L.ApiParamError(fmt::format(FMT_STRING("Cannot read the CallbacksTable parameter at idx {}"), a_UrlStackIdx + 1)); } urlClientCallbacks = std::make_unique<cFullUrlClientCallbacks>(std::move(callbacks)); } @@ -973,17 +979,23 @@ static int tolua_cUrlClient_Request_Common(lua_State * a_LuaState, const AString { if (!L.GetStackValue(a_UrlStackIdx + 1, onCompleteBodyCallback)) { - return L.ApiParamError("Cannot read the CallbackFn parameter at idx %d", a_UrlStackIdx + 1); + return L.ApiParamError(fmt::format(FMT_STRING("Cannot read the CallbackFn parameter at idx {}"), a_UrlStackIdx + 1)); } urlClientCallbacks = std::make_unique<cSimpleUrlClientCallbacks>(std::move(onCompleteBodyCallback)); } else { - L.ApiParamError("Invalid Callbacks parameter at %d, expected a table or function, got %s", a_UrlStackIdx + 1, L.GetTypeText(a_UrlStackIdx + 1).c_str()); + L.ApiParamError(fmt::format( + FMT_STRING("Invalid Callbacks parameter at {}, expected a table or function, got {}"), + a_UrlStackIdx + 1, L.GetTypeText(a_UrlStackIdx + 1) + )); } if (!L.GetStackValues(a_UrlStackIdx + 2, cLuaState::cOptionalParam<AStringMap>(headers), cLuaState::cOptionalParam<AString>(requestBody), cLuaState::cOptionalParam<AStringMap>(options))) { - L.ApiParamError("Cannot read the Header, Body or Options parameter at idx %d, %d, %d.", a_UrlStackIdx + 2, a_UrlStackIdx + 3, a_UrlStackIdx + 4); + L.ApiParamError(fmt::format( + FMT_STRING("Cannot read the Header, Body or Options parameter at idx {}, {}, {}."), + a_UrlStackIdx + 2, a_UrlStackIdx + 3, a_UrlStackIdx + 4 + )); } // Make the request: |