Replace last occurrences of 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG'

The last remaining ERR_EXPLAIN call is in FreeType code and makes sense as is
(conditionally defines the error message).

There are a few ERR_EXPLAINC calls for C-strings where String is not included
which can stay as is to avoid adding additional _MSGC macros just for that.

Part of #31244.
This commit is contained in:
Rémi Verschelde 2019-08-17 13:04:33 +02:00
parent de4aabe89b
commit d3153c28f0
13 changed files with 43 additions and 88 deletions

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* lws_server.cpp */
/* wsl_server.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -64,18 +64,17 @@ bool WSLServer::PendingPeer::_parse_request(const PoolStringArray p_protocols) {
else
headers[name] = value;
}
#define _WLS_CHECK(NAME, VALUE) \
ERR_EXPLAIN("Missing or invalid header '" + String(NAME) + "'. Expected value '" + VALUE + "'"); \
ERR_FAIL_COND_V(!headers.has(NAME) || headers[NAME].to_lower() != VALUE, false);
#define _WLS_CHECK_EX(NAME) \
ERR_EXPLAIN("Missing header '" + String(NAME) + "'."); \
ERR_FAIL_COND_V(!headers.has(NAME), false);
_WLS_CHECK("upgrade", "websocket");
_WLS_CHECK("sec-websocket-version", "13");
_WLS_CHECK_EX("sec-websocket-key");
_WLS_CHECK_EX("connection");
#undef _WLS_CHECK_EX
#undef _WLS_CHECK
#define _WSL_CHECK(NAME, VALUE) \
ERR_FAIL_COND_V_MSG(!headers.has(NAME) || headers[NAME].to_lower() != VALUE, false, \
"Missing or invalid header '" + String(NAME) + "'. Expected value '" + VALUE + "'.");
#define _WSL_CHECK_EX(NAME) \
ERR_FAIL_COND_V_MSG(!headers.has(NAME), false, "Missing header '" + String(NAME) + "'.");
_WSL_CHECK("upgrade", "websocket");
_WSL_CHECK("sec-websocket-version", "13");
_WSL_CHECK_EX("sec-websocket-key");
_WSL_CHECK_EX("connection");
#undef _WSL_CHECK_EX
#undef _WSL_CHECK
key = headers["sec-websocket-key"];
if (headers.has("sec-websocket-protocol")) {
Vector<String> protos = headers["sec-websocket-protocol"].split(",");