mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 14:11:15 +00:00
[Core] Improve error messages with vformat
This commit is contained in:
parent
8004c7524f
commit
38f9769bc6
49 changed files with 292 additions and 292 deletions
|
|
@ -75,7 +75,7 @@ Ref<Resource> ResourceLoader::load(const String &p_path, const String &p_type_hi
|
|||
Error err = OK;
|
||||
Ref<Resource> ret = ::ResourceLoader::load(p_path, p_type_hint, ResourceFormatLoader::CacheMode(p_cache_mode), &err);
|
||||
|
||||
ERR_FAIL_COND_V_MSG(err != OK, ret, "Error loading resource: '" + p_path + "'.");
|
||||
ERR_FAIL_COND_V_MSG(err != OK, ret, vformat("Error loading resource: '%s'.", p_path));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1315,7 +1315,7 @@ void Thread::_start_func(void *ud) {
|
|||
}
|
||||
|
||||
if (ce.error != Callable::CallError::CALL_OK) {
|
||||
ERR_FAIL_MSG("Could not call function '" + func_name + "' to start thread " + t->get_id() + ": " + Variant::get_callable_error_text(t->target_callable, nullptr, 0, ce) + ".");
|
||||
ERR_FAIL_MSG(vformat("Could not call function '%s' to start thread %d: %s.", func_name, t->get_id(), Variant::get_callable_error_text(t->target_callable, nullptr, 0, ce)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1814,8 +1814,8 @@ Object *Engine::get_singleton_object(const StringName &p_name) const {
|
|||
}
|
||||
|
||||
void Engine::register_singleton(const StringName &p_name, Object *p_object) {
|
||||
ERR_FAIL_COND_MSG(has_singleton(p_name), "Singleton already registered: " + String(p_name));
|
||||
ERR_FAIL_COND_MSG(!String(p_name).is_valid_ascii_identifier(), "Singleton name is not a valid identifier: " + p_name);
|
||||
ERR_FAIL_COND_MSG(has_singleton(p_name), vformat("Singleton already registered: '%s'.", String(p_name)));
|
||||
ERR_FAIL_COND_MSG(!String(p_name).is_valid_ascii_identifier(), vformat("Singleton name is not a valid identifier: '%s'.", p_name));
|
||||
::Engine::Singleton s;
|
||||
s.class_name = p_name;
|
||||
s.name = p_name;
|
||||
|
|
@ -1825,8 +1825,8 @@ void Engine::register_singleton(const StringName &p_name, Object *p_object) {
|
|||
}
|
||||
|
||||
void Engine::unregister_singleton(const StringName &p_name) {
|
||||
ERR_FAIL_COND_MSG(!has_singleton(p_name), "Attempt to remove unregistered singleton: " + String(p_name));
|
||||
ERR_FAIL_COND_MSG(!::Engine::get_singleton()->is_singleton_user_created(p_name), "Attempt to remove non-user created singleton: " + String(p_name));
|
||||
ERR_FAIL_COND_MSG(!has_singleton(p_name), vformat("Attempt to remove unregistered singleton: '%s'.", String(p_name)));
|
||||
ERR_FAIL_COND_MSG(!::Engine::get_singleton()->is_singleton_user_created(p_name), vformat("Attempt to remove non-user created singleton: '%s'.", String(p_name)));
|
||||
::Engine::get_singleton()->remove_singleton(p_name);
|
||||
}
|
||||
|
||||
|
|
@ -1970,14 +1970,14 @@ bool EngineDebugger::is_active() {
|
|||
void EngineDebugger::register_profiler(const StringName &p_name, Ref<EngineProfiler> p_profiler) {
|
||||
ERR_FAIL_COND(p_profiler.is_null());
|
||||
ERR_FAIL_COND_MSG(p_profiler->is_bound(), "Profiler already registered.");
|
||||
ERR_FAIL_COND_MSG(profilers.has(p_name) || has_profiler(p_name), "Profiler name already in use: " + p_name);
|
||||
ERR_FAIL_COND_MSG(profilers.has(p_name) || has_profiler(p_name), vformat("Profiler name already in use: '%s'.", p_name));
|
||||
Error err = p_profiler->bind(p_name);
|
||||
ERR_FAIL_COND_MSG(err != OK, "Profiler failed to register with error: " + itos(err));
|
||||
ERR_FAIL_COND_MSG(err != OK, vformat("Profiler failed to register with error: %d.", err));
|
||||
profilers.insert(p_name, p_profiler);
|
||||
}
|
||||
|
||||
void EngineDebugger::unregister_profiler(const StringName &p_name) {
|
||||
ERR_FAIL_COND_MSG(!profilers.has(p_name), "Profiler not registered: " + p_name);
|
||||
ERR_FAIL_COND_MSG(!profilers.has(p_name), vformat("Profiler not registered: '%s'.", p_name));
|
||||
profilers[p_name]->unbind();
|
||||
profilers.erase(p_name);
|
||||
}
|
||||
|
|
@ -2001,7 +2001,7 @@ void EngineDebugger::profiler_enable(const StringName &p_name, bool p_enabled, c
|
|||
}
|
||||
|
||||
void EngineDebugger::register_message_capture(const StringName &p_name, const Callable &p_callable) {
|
||||
ERR_FAIL_COND_MSG(captures.has(p_name) || has_capture(p_name), "Capture already registered: " + p_name);
|
||||
ERR_FAIL_COND_MSG(captures.has(p_name) || has_capture(p_name), vformat("Capture already registered: '%s'.", p_name));
|
||||
captures.insert(p_name, p_callable);
|
||||
Callable &c = captures[p_name];
|
||||
::EngineDebugger::Capture capture(&c, &EngineDebugger::call_capture);
|
||||
|
|
@ -2009,7 +2009,7 @@ void EngineDebugger::register_message_capture(const StringName &p_name, const Ca
|
|||
}
|
||||
|
||||
void EngineDebugger::unregister_message_capture(const StringName &p_name) {
|
||||
ERR_FAIL_COND_MSG(!captures.has(p_name), "Capture not registered: " + p_name);
|
||||
ERR_FAIL_COND_MSG(!captures.has(p_name), vformat("Capture not registered: '%s'.", p_name));
|
||||
::EngineDebugger::unregister_message_capture(p_name);
|
||||
captures.erase(p_name);
|
||||
}
|
||||
|
|
@ -2043,8 +2043,8 @@ Error EngineDebugger::call_capture(void *p_user, const String &p_cmd, const Arra
|
|||
Variant retval;
|
||||
Callable::CallError err;
|
||||
capture.callp(args, 2, retval, err);
|
||||
ERR_FAIL_COND_V_MSG(err.error != Callable::CallError::CALL_OK, FAILED, "Error calling 'capture' to callable: " + Variant::get_callable_error_text(capture, args, 2, err));
|
||||
ERR_FAIL_COND_V_MSG(retval.get_type() != Variant::BOOL, FAILED, "Error calling 'capture' to callable: " + String(capture) + ". Return type is not bool.");
|
||||
ERR_FAIL_COND_V_MSG(err.error != Callable::CallError::CALL_OK, FAILED, vformat("Error calling 'capture' to callable: %s.", Variant::get_callable_error_text(capture, args, 2, err)));
|
||||
ERR_FAIL_COND_V_MSG(retval.get_type() != Variant::BOOL, FAILED, vformat("Error calling 'capture' to callable: '%s'. Return type is not bool.", String(capture)));
|
||||
r_captured = retval;
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue