mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
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:
commit
d97d8c16e7
2 changed files with 19 additions and 31 deletions
|
@ -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) {
|
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);
|
RemoteDebugger *rd = static_cast<RemoteDebugger *>(p_this);
|
||||||
if (rd->flushing && Thread::get_caller_id() == rd->flush_thread) { // Can't handle recursive errors during flush.
|
if (rd->flushing && Thread::get_caller_id() == rd->flush_thread) { // Can't handle recursive errors during flush.
|
||||||
return;
|
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();
|
if (p_is_error_breakpoint && script_debugger->is_ignoring_error_breaks()) {
|
||||||
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);
|
|
||||||
return;
|
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;
|
Input::MouseMode mouse_mode = Input::MOUSE_MODE_VISIBLE;
|
||||||
|
|
||||||
if (Thread::get_caller_id() == Thread::get_main_id()) {
|
if (Thread::get_caller_id() == Thread::get_main_id()) {
|
||||||
|
|
|
@ -522,10 +522,8 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
||||||
}
|
}
|
||||||
int err_line = _initial_line;
|
int err_line = _initial_line;
|
||||||
const char *err_text = "Stack overflow. Check for infinite recursion in your script.";
|
const char *err_text = "Stack overflow. Check for infinite recursion in your script.";
|
||||||
if (!GDScriptLanguage::get_singleton()->debug_break(err_text, false)) {
|
_err_print_error(err_func.utf8().get_data(), err_file.utf8().get_data(), err_line, err_text, false, ERR_HANDLER_SCRIPT);
|
||||||
// Debugger break did not happen.
|
GDScriptLanguage::get_singleton()->debug_break(err_text, false);
|
||||||
_err_print_error(err_func.utf8().get_data(), err_file.utf8().get_data(), err_line, err_text, false, ERR_HANDLER_SCRIPT);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return _get_default_variant_for_data_type(return_type);
|
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).";
|
err_text = "Internal script error! Opcode: " + itos(last_opcode) + " (please report).";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GDScriptLanguage::get_singleton()->debug_break(err_text, false)) {
|
_err_print_error(err_func.utf8().get_data(), err_file.utf8().get_data(), err_line, err_text.utf8().get_data(), false, ERR_HANDLER_SCRIPT);
|
||||||
// debugger break did not happen
|
GDScriptLanguage::get_singleton()->debug_break(err_text, false);
|
||||||
|
|
||||||
_err_print_error(err_func.utf8().get_data(), err_file.utf8().get_data(), err_line, err_text.utf8().get_data(), false, ERR_HANDLER_SCRIPT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a default return type in case of failure
|
// Get a default return type in case of failure
|
||||||
retvalue = _get_default_variant_for_data_type(return_type);
|
retvalue = _get_default_variant_for_data_type(return_type);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue