Fix misuses of error macros

This commit is contained in:
Danil Alexeev 2023-04-18 10:20:48 +03:00
parent d6dde819be
commit 36bedd341a
No known key found for this signature in database
GPG Key ID: 124453E157DA8DC7
11 changed files with 5 additions and 13 deletions

View File

@ -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) { 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; return ERR_UNAVAILABLE;
} }

View File

@ -401,7 +401,6 @@ Color Color::named(const String &p_name) {
int idx = find_named_color(p_name); int idx = find_named_color(p_name);
if (idx == -1) { if (idx == -1) {
ERR_FAIL_V_MSG(Color(), "Invalid color name: " + p_name + "."); ERR_FAIL_V_MSG(Color(), "Invalid color name: " + p_name + ".");
return Color();
} }
return named_colors[idx].color; return named_colors[idx].color;
} }

View File

@ -2193,7 +2193,7 @@ int64_t String::hex_to_int() const {
} else if (c >= 'a' && c <= 'f') { } else if (c >= 'a' && c <= 'f') {
n = (c - 'a') + 10; n = (c - 'a') + 10;
} else { } 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 // 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'); bool overflow = ((hex > INT64_MAX / 16) && (sign == 1 || (sign == -1 && hex != (INT64_MAX >> 4) + 1))) || (sign == -1 && hex == (INT64_MAX >> 4) + 1 && c > '0');

View File

@ -186,7 +186,6 @@ public:
spin_lock.unlock(); spin_lock.unlock();
} }
ERR_FAIL_V_MSG(nullptr, "Attempting to initialize the wrong RID"); ERR_FAIL_V_MSG(nullptr, "Attempting to initialize the wrong RID");
return nullptr;
} }
validator_chunks[idx_chunk][idx_element] &= 0x7FFFFFFF; //initialized validator_chunks[idx_chunk][idx_element] &= 0x7FFFFFFF; //initialized

View File

@ -51,7 +51,7 @@ Error DAPeer::handle_data() {
while (true) { while (true) {
if (req_pos >= DAP_MAX_BUFFER_SIZE) { if (req_pos >= DAP_MAX_BUFFER_SIZE) {
req_pos = 0; 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); Error err = connection->get_partial_data(&req_buf[req_pos], 1, read);
if (err != OK) { if (err != OK) {

View File

@ -46,7 +46,7 @@ Error GDScriptLanguageProtocol::LSPeer::handle_data() {
while (true) { while (true) {
if (req_pos >= LSP_MAX_BUFFER_SIZE) { if (req_pos >= LSP_MAX_BUFFER_SIZE) {
req_pos = 0; 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); Error err = connection->get_partial_data(&req_buf[req_pos], 1, read);
if (err != OK) { if (err != OK) {

View File

@ -1282,7 +1282,7 @@ XrResult OpenXRAPI::get_instance_proc_addr(const char *p_name, PFN_xrVoidFunctio
if (result != XR_SUCCESS) { if (result != XR_SUCCESS) {
String error_message = String("Symbol ") + p_name + " not found in OpenXR instance."; 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; return result;

View File

@ -58,7 +58,6 @@ void image_decompress_squish(Image *p_image) {
squish_flags = squish::kBc5; squish_flags = squish::kBc5;
} else { } else {
ERR_FAIL_MSG("Squish: Can't decompress unknown format: " + itos(p_image->get_format()) + "."); ERR_FAIL_MSG("Squish: Can't decompress unknown format: " + itos(p_image->get_format()) + ".");
return;
} }
for (int i = 0; i <= mm_count; i++) { for (int i = 0; i <= mm_count; i++) {

View File

@ -379,7 +379,6 @@ void WSLPeer::_do_client_handshake() {
// Header is too big // Header is too big
close(-1); close(-1);
ERR_FAIL_MSG("Response headers too big."); ERR_FAIL_MSG("Response headers too big.");
return;
} }
uint8_t byte; uint8_t byte;
@ -402,7 +401,6 @@ void WSLPeer::_do_client_handshake() {
if (!_verify_server_response()) { if (!_verify_server_response()) {
close(-1); close(-1);
ERR_FAIL_MSG("Invalid response headers."); ERR_FAIL_MSG("Invalid response headers.");
return;
} }
wslay_event_context_client_init(&wsl_ctx, &_wsl_callbacks, this); wslay_event_context_client_init(&wsl_ctx, &_wsl_callbacks, this);
wslay_event_config_set_max_recv_msg_length(wsl_ctx, inbound_buffer_size); wslay_event_config_set_max_recv_msg_length(wsl_ctx, inbound_buffer_size);
@ -469,7 +467,6 @@ bool WSLPeer::_verify_server_response() {
} }
if (!valid) { if (!valid) {
ERR_FAIL_V_MSG(false, "Received unrequested sub-protocol -> " + selected_protocol); ERR_FAIL_V_MSG(false, "Received unrequested sub-protocol -> " + selected_protocol);
return false;
} }
} }
return true; return true;

View File

@ -3915,7 +3915,6 @@ DisplayServerMacOS::DisplayServerMacOS(const String &p_rendering_driver, WindowM
gl_manager = nullptr; gl_manager = nullptr;
r_error = ERR_UNAVAILABLE; r_error = ERR_UNAVAILABLE;
ERR_FAIL_MSG("Could not initialize OpenGL"); ERR_FAIL_MSG("Could not initialize OpenGL");
return;
} }
} }
#endif #endif

View File

@ -98,7 +98,6 @@ Variant GodotSoftBody3D::get_state(PhysicsServer3D::BodyState p_state) const {
} break; } break;
case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: { case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: {
ERR_FAIL_V_MSG(Vector3(), "Angular velocity is not supported for Soft bodies."); ERR_FAIL_V_MSG(Vector3(), "Angular velocity is not supported for Soft bodies.");
return Vector3();
} break; } break;
case PhysicsServer3D::BODY_STATE_SLEEPING: { case PhysicsServer3D::BODY_STATE_SLEEPING: {
ERR_FAIL_V_MSG(false, "Sleeping state is not supported for Soft bodies."); ERR_FAIL_V_MSG(false, "Sleeping state is not supported for Soft bodies.");