Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up error_macros.h #33391

Merged
merged 6 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/bind/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ PoolStringArray _ResourceLoader::get_dependencies(const String &p_path) {

#ifndef DISABLE_DEPRECATED
bool _ResourceLoader::has(const String &p_path) {
WARN_PRINTS("ResourceLoader.has() is deprecated, please replace it with the equivalent has_cached() or the new exists().");
WARN_PRINT("ResourceLoader.has() is deprecated, please replace it with the equivalent has_cached() or the new exists().");
return has_cached(p_path);
}
#endif // DISABLE_DEPRECATED
Expand Down Expand Up @@ -3217,7 +3217,7 @@ Ref<JSONParseResult> _JSON::parse(const String &p_json) {
result->error = JSON::parse(p_json, result->result, result->error_string, result->error_line);

if (result->error != OK) {
ERR_PRINTS(vformat("Error parsing JSON at line %s: %s", result->error_line, result->error_string));
ERR_PRINT(vformat("Error parsing JSON at line %s: %s", result->error_line, result->error_string));
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion core/class_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ Object *ClassDB::instance(const StringName &p_class) {
}
#ifdef TOOLS_ENABLED
if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) {
ERR_PRINTS("Class '" + String(p_class) + "' can only be instantiated by editor.");
ERR_PRINT("Class '" + String(p_class) + "' can only be instantiated by editor.");
return NULL;
}
#endif
Expand Down
592 changes: 356 additions & 236 deletions core/error_macros.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@ Image::AlphaMode Image::detect_alpha() const {
Error Image::load(const String &p_path) {
#ifdef DEBUG_ENABLED
if (p_path.begins_with("res://") && ResourceLoader::exists(p_path)) {
WARN_PRINTS("Loaded resource as image file, this will not work on export: '" + p_path + "'. Instead, import the image file as an Image resource and load it normally as a resource.");
WARN_PRINT("Loaded resource as image file, this will not work on export: '" + p_path + "'. Instead, import the image file as an Image resource and load it normally as a resource.");
}
#endif
return ImageLoader::load_image(p_path, this);
Expand Down
2 changes: 1 addition & 1 deletion core/io/config_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Error ConfigFile::_internal_load(const String &p_path, FileAccess *f) {
memdelete(f);
return OK;
} else if (err != OK) {
ERR_PRINTS("ConfgFile::load - " + p_path + ":" + itos(lines) + " error: " + error_text + ".");
ERR_PRINT("ConfgFile::load - " + p_path + ":" + itos(lines) + " error: " + error_text + ".");
memdelete(f);
return err;
}
Expand Down
4 changes: 2 additions & 2 deletions core/io/image_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_c
Error err;
f = FileAccess::open(p_file, FileAccess::READ, &err);
if (!f) {
ERR_PRINTS("Error opening file '" + p_file + "'.");
ERR_PRINT("Error opening file '" + p_file + "'.");
return err;
}
}
Expand All @@ -66,7 +66,7 @@ Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_c
continue;
Error err = loader[i]->load_image(p_image, f, p_force_linear, p_scale);
if (err != OK) {
ERR_PRINTS("Error loading image: " + p_file);
ERR_PRINT("Error loading image: " + p_file);
}

if (err != ERR_FILE_UNRECOGNIZED) {
Expand Down
2 changes: 1 addition & 1 deletion core/io/ip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ IP_Address IP::get_resolve_item_address(ResolverID p_id) const {
resolver->mutex->lock();

if (resolver->queue[p_id].status != IP::RESOLVER_STATUS_DONE) {
ERR_PRINTS("Resolve of '" + resolver->queue[p_id].hostname + "'' didn't complete yet.");
ERR_PRINT("Resolve of '" + resolver->queue[p_id].hostname + "'' didn't complete yet.");
resolver->mutex->unlock();
return IP_Address();
}
Expand Down
16 changes: 8 additions & 8 deletions core/io/multiplayer_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, int
node = root_node->get_node(np);

if (!node)
ERR_PRINTS("Failed to get path from RPC: " + String(np) + ".");
ERR_PRINT("Failed to get path from RPC: " + String(np) + ".");
} else {
// Use cached path.
int id = target;
Expand All @@ -269,7 +269,7 @@ Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, int

node = root_node->get_node(ni->path);
if (!node)
ERR_PRINTS("Failed to get cached path from RPC: " + String(ni->path) + ".");
ERR_PRINT("Failed to get cached path from RPC: " + String(ni->path) + ".");
}
return node;
}
Expand Down Expand Up @@ -324,7 +324,7 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const StringName &p_name, int p_
if (ce.error != Variant::CallError::CALL_OK) {
String error = Variant::get_call_error_text(p_node, p_name, (const Variant **)argp.ptr(), argc, ce);
error = "RPC - " + error;
ERR_PRINTS(error);
ERR_PRINT(error);
}
}

Expand Down Expand Up @@ -362,7 +362,7 @@ void MultiplayerAPI::_process_rset(Node *p_node, const StringName &p_name, int p
p_node->set(p_name, value, &valid);
if (!valid) {
String error = "Error setting remote property '" + String(p_name) + "', not found in object of type " + p_node->get_class() + ".";
ERR_PRINTS(error);
ERR_PRINT(error);
}
}

Expand Down Expand Up @@ -683,7 +683,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
if (ce.error != Variant::CallError::CALL_OK) {
String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce);
error = "rpc() aborted in local call: - " + error + ".";
ERR_PRINTS(error);
ERR_PRINT(error);
return;
}
}
Expand All @@ -698,7 +698,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
if (ce.error != Variant::CallError::CALL_OK) {
String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce);
error = "rpc() aborted in script local call: - " + error + ".";
ERR_PRINTS(error);
ERR_PRINT(error);
return;
}
}
Expand Down Expand Up @@ -735,7 +735,7 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const

if (!valid) {
String error = "rset() aborted in local set, property not found: - " + String(p_property) + ".";
ERR_PRINTS(error);
ERR_PRINT(error);
return;
}
} else if (p_node->get_script_instance()) {
Expand All @@ -753,7 +753,7 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const

if (!valid) {
String error = "rset() aborted in local script set, property not found: - " + String(p_property) + ".";
ERR_PRINTS(error);
ERR_PRINT(error);
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/io/packet_peer_udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Error PacketPeerUDP::_poll() {

if (rb.space_left() < read + 24) {
#ifdef TOOLS_ENABLED
WARN_PRINTS("Buffer full, dropping packets!");
WARN_PRINT("Buffer full, dropping packets!");
#endif
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions core/io/resource_format_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
memdelete(da);
//use the old approach

WARN_PRINTS("This file is old, so it can't refactor dependencies, opening and resaving '" + p_path + "'.");
WARN_PRINT("This file is old, so it can't refactor dependencies, opening and resaving '" + p_path + "'.");

Error err;
f = FileAccess::open(p_path, FileAccess::READ, &err);
Expand Down Expand Up @@ -1635,7 +1635,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant

if (!p_main && (!bundle_resources) && res->get_path().length() && res->get_path().find("::") == -1) {
if (res->get_path() == path) {
ERR_PRINTS("Circular reference to resource being saved found: '" + local_path + "' will be null next time it's loaded.");
ERR_PRINT("Circular reference to resource being saved found: '" + local_path + "' will be null next time it's loaded.");
return;
}
int idx = external_resources.size();
Expand Down
4 changes: 2 additions & 2 deletions core/io/resource_importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
memdelete(f);
return OK;
} else if (err != OK) {
ERR_PRINTS("ResourceFormatImporter::load - " + p_path + ".import:" + itos(lines) + " error: " + error_text);
ERR_PRINT("ResourceFormatImporter::load - " + p_path + ".import:" + itos(lines) + " error: " + error_text);
memdelete(f);
return err;
}
Expand Down Expand Up @@ -279,7 +279,7 @@ void ResourceFormatImporter::get_internal_resource_path_list(const String &p_pat
memdelete(f);
return;
} else if (err != OK) {
ERR_PRINTS("ResourceFormatImporter::get_internal_resource_path_list - " + p_path + ".import:" + itos(lines) + " error: " + error_text);
ERR_PRINT("ResourceFormatImporter::get_internal_resource_path_list - " + p_path + ".import:" + itos(lines) + " error: " + error_text);
memdelete(f);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions core/io/resource_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
if (err == ERR_FILE_EOF) {
break;
} else if (err != OK) {
ERR_PRINTS("Parse error: " + p_path + ".remap:" + itos(lines) + " error: " + error_text + ".");
ERR_PRINT("Parse error: " + p_path + ".remap:" + itos(lines) + " error: " + error_text + ".");
break;
}

Expand Down Expand Up @@ -1013,7 +1013,7 @@ void ResourceLoader::finalize() {
#ifndef NO_THREADS
const LoadingMapKey *K = NULL;
while ((K = loading_map.next(K))) {
ERR_PRINTS("Exited while resource is being loaded: " + K->path);
ERR_PRINT("Exited while resource is being loaded: " + K->path);
}
loading_map.clear();
memdelete(loading_map_mutex);
Expand Down
2 changes: 1 addition & 1 deletion core/math/bsp_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ static int _bsp_create_node(const Face3 *p_faces, const Vector<int> &p_indices,
ERR_FAIL_COND_V(p_nodes.size() == BSP_Tree::MAX_NODES, -1);

// should not reach here
ERR_FAIL_COND_V(p_indices.size() == 0, -1)
ERR_FAIL_COND_V(p_indices.size() == 0, -1);

int ic = p_indices.size();
const int *indices = p_indices.ptr();
Expand Down
2 changes: 1 addition & 1 deletion core/message_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void MessageQueue::_call_function(Object *p_target, const StringName &p_func, co
p_target->call(p_func, argptrs, p_argcount, ce);
if (p_show_error && ce.error != Variant::CallError::CALL_OK) {

ERR_PRINTS("Error calling deferred method: " + Variant::get_call_error_text(p_target, p_func, argptrs, p_argcount, ce) + ".");
ERR_PRINT("Error calling deferred method: " + Variant::get_call_error_text(p_target, p_func, argptrs, p_argcount, ce) + ".");
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
if (ce.error == Variant::CallError::CALL_ERROR_INVALID_METHOD && !ClassDB::class_exists(target->get_class_name())) {
//most likely object is not initialized yet, do not throw error.
} else {
ERR_PRINTS("Error calling method from signal '" + String(p_name) + "': " + Variant::get_call_error_text(target, c.method, args, argc, ce) + ".");
ERR_PRINT("Error calling method from signal '" + String(p_name) + "': " + Variant::get_call_error_text(target, c.method, args, argc, ce) + ".");
err = ERR_METHOD_NOT_FOUND;
}
}
Expand Down Expand Up @@ -1945,7 +1945,7 @@ Object::~Object() {

if (_emitting) {
//@todo this may need to actually reach the debugger prioritarily somehow because it may crash before
ERR_PRINTS("Object " + to_string() + " was freed or unreferenced while a signal is being emitted from it. Try connecting to the signal using 'CONNECT_DEFERRED' flag, or use queue_free() to free the object (if this object is a Node) to avoid this error and potential crashes.");
ERR_PRINT("Object " + to_string() + " was freed or unreferenced while a signal is being emitted from it. Try connecting to the signal using 'CONNECT_DEFERRED' flag, or use queue_free() to free the object (if this object is a Node) to avoid this error and potential crashes.");
}

while ((S = signal_map.next(NULL))) {
Expand Down
4 changes: 2 additions & 2 deletions core/os/dir_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) {
FileAccess *fsrc = FileAccess::open(p_from, FileAccess::READ, &err);

if (err) {
ERR_PRINTS("Failed to open " + p_from);
ERR_PRINT("Failed to open " + p_from);
return err;
}

Expand All @@ -294,7 +294,7 @@ Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) {

fsrc->close();
memdelete(fsrc);
ERR_PRINTS("Failed to open " + p_to);
ERR_PRINT("Failed to open " + p_to);
return err;
}

Expand Down
2 changes: 1 addition & 1 deletion core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ int OS::get_process_id() const {

void OS::vibrate_handheld(int p_duration_ms) {

WARN_PRINTS("vibrate_handheld() only works with Android and iOS");
WARN_PRINT("vibrate_handheld() only works with Android and iOS");
}

bool OS::is_stdout_verbose() const {
Expand Down
6 changes: 3 additions & 3 deletions core/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ bool ProjectSettings::_get(const StringName &p_name, Variant &r_ret) const {
name = feature_overrides[name];
}
if (!props.has(name)) {
WARN_PRINTS("Property not found: " + String(name));
WARN_PRINT("Property not found: " + String(name));
return false;
}
r_ret = props[name].variant;
Expand Down Expand Up @@ -579,7 +579,7 @@ Error ProjectSettings::_load_settings_text(const String &p_path) {
_convert_to_last_version(config_version);
return OK;
} else if (err != OK) {
ERR_PRINTS("Error parsing " + p_path + " at line " + itos(lines) + ": " + error_text + " File might be corrupted.");
ERR_PRINT("Error parsing " + p_path + " at line " + itos(lines) + ": " + error_text + " File might be corrupted.");
memdelete(f);
return err;
}
Expand Down Expand Up @@ -612,7 +612,7 @@ Error ProjectSettings::_load_settings_text_or_binary(const String &p_text_path,
return OK;
} else if (err_text != ERR_FILE_NOT_FOUND) {
// If the text-based file exists but can't be loaded, we want to know it
ERR_PRINTS("Couldn't load file '" + p_text_path + "', error code " + itos(err_text) + ".");
ERR_PRINT("Couldn't load file '" + p_text_path + "', error code " + itos(err_text) + ".");
return err_text;
}

Expand Down
2 changes: 1 addition & 1 deletion core/translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ void TranslationServer::set_locale(const String &p_locale) {
print_verbose(vformat("Unsupported locale '%s', falling back to '%s'.", p_locale, trimmed_locale));

if (!is_locale_valid(trimmed_locale)) {
ERR_PRINTS(vformat("Unsupported locale '%s', falling back to 'en'.", trimmed_locale));
ERR_PRINT(vformat("Unsupported locale '%s', falling back to 'en'.", trimmed_locale));
locale = "en";
} else {
locale = trimmed_locale;
Expand Down
2 changes: 1 addition & 1 deletion core/type_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ struct GetTypeInfo<const T *, typename EnableIf<TypeInherits<Object, T>::value>:
template <typename T>
inline StringName __constant_get_enum_name(T param, const String &p_constant) {
if (GetTypeInfo<T>::VARIANT_TYPE == Variant::NIL)
ERR_PRINTS("Missing VARIANT_ENUM_CAST for constant's enum: " + p_constant);
ERR_PRINT("Missing VARIANT_ENUM_CAST for constant's enum: " + p_constant);
return GetTypeInfo<T>::get_class_info().class_name;
}

Expand Down
2 changes: 1 addition & 1 deletion core/undo_redo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
Variant::CallError ce;
obj->call(op.name, (const Variant **)argptrs.ptr(), argc, ce);
if (ce.error != Variant::CallError::CALL_OK) {
ERR_PRINTS("Error calling method from signal '" + String(op.name) + "': " + Variant::get_call_error_text(obj, op.name, (const Variant **)argptrs.ptr(), argc, ce));
ERR_PRINT("Error calling method from signal '" + String(op.name) + "': " + Variant::get_call_error_text(obj, op.name, (const Variant **)argptrs.ptr(), argc, ce));
}
#ifdef TOOLS_ENABLED
Resource *res = Object::cast_to<Resource>(obj);
Expand Down
2 changes: 1 addition & 1 deletion drivers/alsa/audio_driver_alsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void AudioDriverALSA::thread_func(void *p_udata) {
} else {
wrote = snd_pcm_recover(ad->pcm_handle, wrote, 0);
if (wrote < 0) {
ERR_PRINTS("ALSA: Failed and can't recover: " + String(snd_strerror(wrote)));
ERR_PRINT("ALSA: Failed and can't recover: " + String(snd_strerror(wrote)));
ad->active = false;
ad->exit_thread = true;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/alsamidi/midi_driver_alsamidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void MIDIDriverALSAMidi::thread_func(void *p_udata) {
ret = snd_rawmidi_read(midi_in, &byte, 1);
if (ret < 0) {
if (ret != -EAGAIN) {
ERR_PRINTS("snd_rawmidi_read error: " + String(snd_strerror(ret)));
ERR_PRINT("snd_rawmidi_read error: " + String(snd_strerror(ret)));
}
} else {
if (byte & 0x80) {
Expand Down
10 changes: 5 additions & 5 deletions drivers/coreaudio/audio_driver_coreaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ OSStatus AudioDriverCoreAudio::input_callback(void *inRefCon,
}
}
} else {
ERR_PRINTS("AudioUnitRender failed, code: " + itos(result));
ERR_PRINT("AudioUnitRender failed, code: " + itos(result));
}

ad->unlock();
Expand All @@ -253,7 +253,7 @@ void AudioDriverCoreAudio::start() {
if (!active) {
OSStatus result = AudioOutputUnitStart(audio_unit);
if (result != noErr) {
ERR_PRINTS("AudioOutputUnitStart failed, code: " + itos(result));
ERR_PRINT("AudioOutputUnitStart failed, code: " + itos(result));
} else {
active = true;
}
Expand All @@ -264,7 +264,7 @@ void AudioDriverCoreAudio::stop() {
if (active) {
OSStatus result = AudioOutputUnitStop(audio_unit);
if (result != noErr) {
ERR_PRINTS("AudioOutputUnitStop failed, code: " + itos(result));
ERR_PRINT("AudioOutputUnitStop failed, code: " + itos(result));
} else {
active = false;
}
Expand Down Expand Up @@ -491,7 +491,7 @@ Error AudioDriverCoreAudio::capture_start() {

OSStatus result = AudioOutputUnitStart(input_unit);
if (result != noErr) {
ERR_PRINTS("AudioOutputUnitStart failed, code: " + itos(result));
ERR_PRINT("AudioOutputUnitStart failed, code: " + itos(result));
}

return OK;
Expand All @@ -502,7 +502,7 @@ Error AudioDriverCoreAudio::capture_stop() {
if (input_unit) {
OSStatus result = AudioOutputUnitStop(input_unit);
if (result != noErr) {
ERR_PRINTS("AudioOutputUnitStop failed, code: " + itos(result));
ERR_PRINT("AudioOutputUnitStop failed, code: " + itos(result));
}
}

Expand Down
Loading