diff options
author | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-10-11 16:17:49 +0200 |
---|---|---|
committer | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-10-30 15:55:51 +0100 |
commit | 38f9769bc6d560373df961880f99aaaafaae00d9 (patch) | |
tree | 4bb21478d3cefde5c03c864bbaf65a31c1f7576a /core/debugger | |
parent | 8004c7524fb9f43425c4d6f614410a76678e0f7c (diff) | |
download | redot-engine-38f9769bc6d560373df961880f99aaaafaae00d9.tar.gz |
[Core] Improve error messages with `vformat`
Diffstat (limited to 'core/debugger')
-rw-r--r-- | core/debugger/engine_debugger.cpp | 18 | ||||
-rw-r--r-- | core/debugger/remote_debugger.cpp | 4 | ||||
-rw-r--r-- | core/debugger/remote_debugger_peer.cpp | 2 |
3 files changed, 12 insertions, 12 deletions
diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp index 97a020e4c3..6d2868cef2 100644 --- a/core/debugger/engine_debugger.cpp +++ b/core/debugger/engine_debugger.cpp @@ -46,12 +46,12 @@ HashMap<String, EngineDebugger::CreatePeerFunc> EngineDebugger::protocols; void (*EngineDebugger::allow_focus_steal_fn)(); void EngineDebugger::register_profiler(const StringName &p_name, const Profiler &p_func) { - ERR_FAIL_COND_MSG(profilers.has(p_name), "Profiler already registered: " + p_name); + ERR_FAIL_COND_MSG(profilers.has(p_name), vformat("Profiler already registered: '%s'.", p_name)); profilers.insert(p_name, p_func); } 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)); Profiler &p = profilers[p_name]; if (p.active && p.toggle) { p.toggle(p.data, false, Array()); @@ -61,22 +61,22 @@ void EngineDebugger::unregister_profiler(const StringName &p_name) { } void EngineDebugger::register_message_capture(const StringName &p_name, Capture p_func) { - ERR_FAIL_COND_MSG(captures.has(p_name), "Capture already registered: " + p_name); + ERR_FAIL_COND_MSG(captures.has(p_name), vformat("Capture already registered: '%s'.", p_name)); captures.insert(p_name, p_func); } 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)); captures.erase(p_name); } void EngineDebugger::register_uri_handler(const String &p_protocol, CreatePeerFunc p_func) { - ERR_FAIL_COND_MSG(protocols.has(p_protocol), "Protocol handler already registered: " + p_protocol); + ERR_FAIL_COND_MSG(protocols.has(p_protocol), vformat("Protocol handler already registered: '%s'.", p_protocol)); protocols.insert(p_protocol, p_func); } void EngineDebugger::profiler_enable(const StringName &p_name, bool p_enabled, const Array &p_opts) { - ERR_FAIL_COND_MSG(!profilers.has(p_name), "Can't change profiler state, no profiler: " + p_name); + ERR_FAIL_COND_MSG(!profilers.has(p_name), vformat("Can't change profiler state, no profiler: '%s'.", p_name)); Profiler &p = profilers[p_name]; if (p.toggle) { p.toggle(p.data, p_enabled, p_opts); @@ -85,7 +85,7 @@ void EngineDebugger::profiler_enable(const StringName &p_name, bool p_enabled, c } void EngineDebugger::profiler_add_frame_data(const StringName &p_name, const Array &p_data) { - ERR_FAIL_COND_MSG(!profilers.has(p_name), "Can't add frame data, no profiler: " + p_name); + ERR_FAIL_COND_MSG(!profilers.has(p_name), vformat("Can't add frame data, no profiler: '%s'.", p_name)); Profiler &p = profilers[p_name]; if (p.add) { p.add(p.data, p_data); @@ -106,7 +106,7 @@ bool EngineDebugger::has_capture(const StringName &p_name) { Error EngineDebugger::capture_parse(const StringName &p_name, const String &p_msg, const Array &p_args, bool &r_captured) { r_captured = false; - ERR_FAIL_COND_V_MSG(!captures.has(p_name), ERR_UNCONFIGURED, "Capture not registered: " + p_name); + ERR_FAIL_COND_V_MSG(!captures.has(p_name), ERR_UNCONFIGURED, vformat("Capture not registered: '%s'.", p_name)); const Capture &cap = captures[p_name]; return cap.capture(cap.data, p_msg, p_args, r_captured); } @@ -164,7 +164,7 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, co for (int i = 0; i < p_breakpoints.size(); i++) { const String &bp = p_breakpoints[i]; int sp = bp.rfind(":"); - ERR_CONTINUE_MSG(sp == -1, "Invalid breakpoint: '" + bp + "', expected file:line format."); + ERR_CONTINUE_MSG(sp == -1, vformat("Invalid breakpoint: '%s', expected file:line format.", bp)); singleton_script_debugger->insert_breakpoint(bp.substr(sp + 1, bp.length()).to_int(), bp.substr(0, sp)); } diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index fc1b7b74f9..a02354b377 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -79,7 +79,7 @@ public: for (int i = 0; i < custom_monitor_names.size(); i++) { Variant monitor_value = performance->call("get_custom_monitor", custom_monitor_names[i]); if (!monitor_value.is_num()) { - ERR_PRINT("Value of custom monitor '" + String(custom_monitor_names[i]) + "' is not a number"); + ERR_PRINT(vformat("Value of custom monitor '%s' is not a number.", String(custom_monitor_names[i]))); arr[i + max] = Variant(); } else { arr[i + max] = monitor_value; @@ -569,7 +569,7 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) { bool captured = false; ERR_CONTINUE(_try_capture(command, data, captured) != OK); if (!captured) { - WARN_PRINT("Unknown message received from debugger: " + command); + WARN_PRINT(vformat("Unknown message received from debugger: %s.", command)); } } } else { diff --git a/core/debugger/remote_debugger_peer.cpp b/core/debugger/remote_debugger_peer.cpp index 9dca47a0b4..793db7330f 100644 --- a/core/debugger/remote_debugger_peer.cpp +++ b/core/debugger/remote_debugger_peer.cpp @@ -178,7 +178,7 @@ Error RemoteDebuggerPeerTCP::connect_to_host(const String &p_host, uint16_t p_po } if (tcp_client->get_status() != StreamPeerTCP::STATUS_CONNECTED) { - ERR_PRINT("Remote Debugger: Unable to connect. Status: " + String::num(tcp_client->get_status()) + "."); + ERR_PRINT(vformat("Remote Debugger: Unable to connect. Status: %s.", String::num(tcp_client->get_status()))); return FAILED; } connected = true; |