mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Fix misuses of error macros
This commit is contained in:
parent
d6dde819be
commit
36bedd341a
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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');
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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++) {
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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.");
|
||||
|
Loading…
Reference in New Issue
Block a user