summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanil Alexeev <danil@alexeev.xyz>2023-04-18 10:20:48 +0300
committerDanil Alexeev <danil@alexeev.xyz>2023-04-18 10:20:48 +0300
commit36bedd341a3f9e1a335a795cfb4b3c73f18903a2 (patch)
tree3831c82cce2f9eef41f2295a46b19b66ae26af2f
parentd6dde819be6e02de133fe1b9f97c8fa6ce8668bb (diff)
downloadredot-engine-36bedd341a3f9e1a335a795cfb4b3c73f18903a2.tar.gz
Fix misuses of error macros
-rw-r--r--core/io/file_access_pack.cpp2
-rw-r--r--core/math/color.cpp1
-rw-r--r--core/string/ustring.cpp2
-rw-r--r--core/templates/rid_owner.h1
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_protocol.cpp2
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.cpp2
-rw-r--r--modules/openxr/openxr_api.cpp2
-rw-r--r--modules/squish/image_decompress_squish.cpp1
-rw-r--r--modules/websocket/wsl_peer.cpp3
-rw-r--r--platform/macos/display_server_macos.mm1
-rw-r--r--servers/physics_3d/godot_soft_body_3d.cpp1
11 files changed, 5 insertions, 13 deletions
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index 9553f35b19..88a906a38e 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -260,7 +260,7 @@ Ref<FileAccess> PackedSourcePCK::get_file(const String &p_path, PackedData::Pack
//////////////////////////////////////////////////////////////////
Error FileAccessPack::open_internal(const String &p_path, int p_mode_flags) {
- ERR_FAIL_V(ERR_UNAVAILABLE);
+ ERR_PRINT("Can't open pack-referenced file.");
return ERR_UNAVAILABLE;
}
diff --git a/core/math/color.cpp b/core/math/color.cpp
index 3e5fa7b402..0d9325f236 100644
--- a/core/math/color.cpp
+++ b/core/math/color.cpp
@@ -401,7 +401,6 @@ Color Color::named(const String &p_name) {
int idx = find_named_color(p_name);
if (idx == -1) {
ERR_FAIL_V_MSG(Color(), "Invalid color name: " + p_name + ".");
- return Color();
}
return named_colors[idx].color;
}
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index 73b5bc2d56..49c72a9dcf 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -2193,7 +2193,7 @@ int64_t String::hex_to_int() const {
} else if (c >= 'a' && c <= 'f') {
n = (c - 'a') + 10;
} else {
- ERR_FAIL_COND_V_MSG(true, 0, "Invalid hexadecimal notation character \"" + chr(*s) + "\" in string \"" + *this + "\".");
+ ERR_FAIL_V_MSG(0, vformat(R"(Invalid hexadecimal notation character "%c" (U+%04X) in string "%s".)", *s, static_cast<int32_t>(*s), *this));
}
// Check for overflow/underflow, with special case to ensure INT64_MIN does not result in error
bool overflow = ((hex > INT64_MAX / 16) && (sign == 1 || (sign == -1 && hex != (INT64_MAX >> 4) + 1))) || (sign == -1 && hex == (INT64_MAX >> 4) + 1 && c > '0');
diff --git a/core/templates/rid_owner.h b/core/templates/rid_owner.h
index aa858b4796..9ccd7bb0bf 100644
--- a/core/templates/rid_owner.h
+++ b/core/templates/rid_owner.h
@@ -186,7 +186,6 @@ public:
spin_lock.unlock();
}
ERR_FAIL_V_MSG(nullptr, "Attempting to initialize the wrong RID");
- return nullptr;
}
validator_chunks[idx_chunk][idx_element] &= 0x7FFFFFFF; //initialized
diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
index 4a95047a71..f85163cd6a 100644
--- a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
+++ b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp
@@ -51,7 +51,7 @@ Error DAPeer::handle_data() {
while (true) {
if (req_pos >= DAP_MAX_BUFFER_SIZE) {
req_pos = 0;
- ERR_FAIL_COND_V_MSG(true, ERR_OUT_OF_MEMORY, "Response header too big");
+ ERR_FAIL_V_MSG(ERR_OUT_OF_MEMORY, "Response header too big");
}
Error err = connection->get_partial_data(&req_buf[req_pos], 1, read);
if (err != OK) {
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp
index 0aa53c1dbe..112db4df3a 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.cpp
+++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp
@@ -46,7 +46,7 @@ Error GDScriptLanguageProtocol::LSPeer::handle_data() {
while (true) {
if (req_pos >= LSP_MAX_BUFFER_SIZE) {
req_pos = 0;
- ERR_FAIL_COND_V_MSG(true, ERR_OUT_OF_MEMORY, "Response header too big");
+ ERR_FAIL_V_MSG(ERR_OUT_OF_MEMORY, "Response header too big");
}
Error err = connection->get_partial_data(&req_buf[req_pos], 1, read);
if (err != OK) {
diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp
index d1680612d9..5879fbd460 100644
--- a/modules/openxr/openxr_api.cpp
+++ b/modules/openxr/openxr_api.cpp
@@ -1282,7 +1282,7 @@ XrResult OpenXRAPI::get_instance_proc_addr(const char *p_name, PFN_xrVoidFunctio
if (result != XR_SUCCESS) {
String error_message = String("Symbol ") + p_name + " not found in OpenXR instance.";
- ERR_FAIL_COND_V_MSG(true, result, error_message.utf8().get_data());
+ ERR_FAIL_V_MSG(result, error_message.utf8().get_data());
}
return result;
diff --git a/modules/squish/image_decompress_squish.cpp b/modules/squish/image_decompress_squish.cpp
index 01be72a27e..5b35a2643a 100644
--- a/modules/squish/image_decompress_squish.cpp
+++ b/modules/squish/image_decompress_squish.cpp
@@ -58,7 +58,6 @@ void image_decompress_squish(Image *p_image) {
squish_flags = squish::kBc5;
} else {
ERR_FAIL_MSG("Squish: Can't decompress unknown format: " + itos(p_image->get_format()) + ".");
- return;
}
for (int i = 0; i <= mm_count; i++) {
diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp
index 8a150c8561..816d5276b9 100644
--- a/modules/websocket/wsl_peer.cpp
+++ b/modules/websocket/wsl_peer.cpp
@@ -379,7 +379,6 @@ void WSLPeer::_do_client_handshake() {
// Header is too big
close(-1);
ERR_FAIL_MSG("Response headers too big.");
- return;
}
uint8_t byte;
@@ -402,7 +401,6 @@ void WSLPeer::_do_client_handshake() {
if (!_verify_server_response()) {
close(-1);
ERR_FAIL_MSG("Invalid response headers.");
- return;
}
wslay_event_context_client_init(&wsl_ctx, &_wsl_callbacks, this);
wslay_event_config_set_max_recv_msg_length(wsl_ctx, inbound_buffer_size);
@@ -469,7 +467,6 @@ bool WSLPeer::_verify_server_response() {
}
if (!valid) {
ERR_FAIL_V_MSG(false, "Received unrequested sub-protocol -> " + selected_protocol);
- return false;
}
}
return true;
diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm
index ac3a861d84..296abbfe12 100644
--- a/platform/macos/display_server_macos.mm
+++ b/platform/macos/display_server_macos.mm
@@ -3915,7 +3915,6 @@ DisplayServerMacOS::DisplayServerMacOS(const String &p_rendering_driver, WindowM
gl_manager = nullptr;
r_error = ERR_UNAVAILABLE;
ERR_FAIL_MSG("Could not initialize OpenGL");
- return;
}
}
#endif
diff --git a/servers/physics_3d/godot_soft_body_3d.cpp b/servers/physics_3d/godot_soft_body_3d.cpp
index 1820a29553..5c67807c48 100644
--- a/servers/physics_3d/godot_soft_body_3d.cpp
+++ b/servers/physics_3d/godot_soft_body_3d.cpp
@@ -98,7 +98,6 @@ Variant GodotSoftBody3D::get_state(PhysicsServer3D::BodyState p_state) const {
} break;
case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: {
ERR_FAIL_V_MSG(Vector3(), "Angular velocity is not supported for Soft bodies.");
- return Vector3();
} break;
case PhysicsServer3D::BODY_STATE_SLEEPING: {
ERR_FAIL_V_MSG(false, "Sleeping state is not supported for Soft bodies.");