Merge pull request #107663 from mihe/script-break-error

Fix errors not being emitted when debugger breaks on script errors
This commit is contained in:
Thaddeus Crews 2025-06-24 09:58:38 -05:00
commit d97d8c16e7
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
2 changed files with 19 additions and 31 deletions

View file

@ -104,10 +104,6 @@ Error RemoteDebugger::_put_msg(const String &p_message, const Array &p_data) {
}
void RemoteDebugger::_err_handler(void *p_this, const char *p_func, const char *p_file, int p_line, const char *p_err, const char *p_descr, bool p_editor_notify, ErrorHandlerType p_type) {
if (p_type == ERR_HANDLER_SCRIPT) {
return; //ignore script errors, those go through debugger
}
RemoteDebugger *rd = static_cast<RemoteDebugger *>(p_this);
if (rd->flushing && Thread::get_caller_id() == rd->flush_thread) { // Can't handle recursive errors during flush.
return;
@ -407,27 +403,24 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
}
}
ScriptLanguage *script_lang = script_debugger->get_break_language();
ERR_FAIL_NULL(script_lang);
const bool can_break = !(p_is_error_breakpoint && script_debugger->is_ignoring_error_breaks());
const String error_str = script_lang ? script_lang->debug_get_error() : "";
if (can_break) {
Array msg = {
p_can_continue,
error_str,
script_lang->debug_get_stack_level_count() > 0,
Thread::get_caller_id()
};
if (allow_focus_steal_fn) {
allow_focus_steal_fn();
}
send_message("debug_enter", msg);
} else {
ERR_PRINT(error_str);
if (p_is_error_breakpoint && script_debugger->is_ignoring_error_breaks()) {
return;
}
ScriptLanguage *script_lang = script_debugger->get_break_language();
ERR_FAIL_NULL(script_lang);
Array msg = {
p_can_continue,
script_lang->debug_get_error(),
script_lang->debug_get_stack_level_count() > 0,
Thread::get_caller_id()
};
if (allow_focus_steal_fn) {
allow_focus_steal_fn();
}
send_message("debug_enter", msg);
Input::MouseMode mouse_mode = Input::MOUSE_MODE_VISIBLE;
if (Thread::get_caller_id() == Thread::get_main_id()) {

View file

@ -522,10 +522,8 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
int err_line = _initial_line;
const char *err_text = "Stack overflow. Check for infinite recursion in your script.";
if (!GDScriptLanguage::get_singleton()->debug_break(err_text, false)) {
// Debugger break did not happen.
_err_print_error(err_func.utf8().get_data(), err_file.utf8().get_data(), err_line, err_text, false, ERR_HANDLER_SCRIPT);
}
_err_print_error(err_func.utf8().get_data(), err_file.utf8().get_data(), err_line, err_text, false, ERR_HANDLER_SCRIPT);
GDScriptLanguage::get_singleton()->debug_break(err_text, false);
#endif
return _get_default_variant_for_data_type(return_type);
}
@ -3939,11 +3937,8 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
err_text = "Internal script error! Opcode: " + itos(last_opcode) + " (please report).";
}
if (!GDScriptLanguage::get_singleton()->debug_break(err_text, false)) {
// debugger break did not happen
_err_print_error(err_func.utf8().get_data(), err_file.utf8().get_data(), err_line, err_text.utf8().get_data(), false, ERR_HANDLER_SCRIPT);
}
_err_print_error(err_func.utf8().get_data(), err_file.utf8().get_data(), err_line, err_text.utf8().get_data(), false, ERR_HANDLER_SCRIPT);
GDScriptLanguage::get_singleton()->debug_break(err_text, false);
// Get a default return type in case of failure
retvalue = _get_default_variant_for_data_type(return_type);