provide script name in errors

This commit is contained in:
Face
2025-09-10 17:19:03 +03:00
parent 6cf5d2f19c
commit e49f9887f0
4 changed files with 21 additions and 13 deletions

View File

@@ -451,7 +451,7 @@ func process_scripts(lua_api: LuaAPI, _lua_vm) -> void:
parse_result.external_scripts = []
parse_result.external_scripts.append(src)
elif not inline_code.is_empty():
lua_api.execute_lua_script(inline_code)
lua_api.execute_lua_script(inline_code, "<inline script>")
func process_external_scripts(lua_api: LuaAPI, _lua_vm, base_url: String = "") -> void:
if not lua_api or not parse_result.external_scripts or parse_result.external_scripts.is_empty():
@@ -462,7 +462,7 @@ func process_external_scripts(lua_api: LuaAPI, _lua_vm, base_url: String = "") -
for script_url in parse_result.external_scripts:
var script_content = await Network.fetch_external_resource(script_url, base_url)
if not script_content.is_empty():
lua_api.execute_lua_script(script_content)
lua_api.execute_lua_script(script_content, script_url)
func process_postprocess() -> HTMLParser.HTMLElement:
var postprocess_elements = find_all("postprocess")

View File

@@ -660,13 +660,13 @@ func get_dom_node(node: Node, purpose: String = "general") -> Node:
return node
# Main execution function
func execute_lua_script(code: String):
func execute_lua_script(code: String, chunk_name: String = "dostring"):
if not threaded_vm.lua_thread or not threaded_vm.lua_thread.is_alive():
# Start the thread if it's not running
threaded_vm.start_lua_thread(dom_parser, self)
script_start_time = Time.get_ticks_msec() / 1000.0
threaded_vm.execute_script_async(code)
threaded_vm.execute_script_async(code, chunk_name)
func _on_threaded_script_completed(_result: Dictionary):
pass