From 0be18493a943b5e694568ea3d5de906aa0632fe8 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Fri, 14 Apr 2023 21:22:22 +0200 Subject: [PATCH] Show error message in crash message box (#1461) * Save to `error.txt` the same traceback shown on stdout * Show error message in crash message box --- src/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index f6e980a5..e3a9b1ac 100644 --- a/src/main.c +++ b/src/main.c @@ -237,22 +237,23 @@ init_lua: " core.init()\n" " core.run()\n" "end, function(err)\n" - " local error_dir\n" + " local error_path = 'error.txt'\n" " io.stdout:write('Error: '..tostring(err)..'\\n')\n" " io.stdout:write(debug.traceback(nil, 2)..'\\n')\n" " if core and core.on_error then\n" - " error_dir=USERDIR\n" + " error_path = USERDIR .. PATHSEP .. error_path\n" " pcall(core.on_error, err)\n" " else\n" - " error_dir=system.absolute_path('.')\n" - " local fp = io.open('error.txt', 'wb')\n" + " local fp = io.open(error_path, 'wb')\n" " fp:write('Error: ' .. tostring(err) .. '\\n')\n" - " fp:write(debug.traceback(nil, 4)..'\\n')\n" + " fp:write(debug.traceback(nil, 2)..'\\n')\n" " fp:close()\n" + " error_path = system.absolute_path(error_path)\n" " end\n" " system.show_fatal_error('Lite XL internal error',\n" " 'An internal error occurred in a critical part of the application.\\n\\n'..\n" - " 'Please verify the file \\\"error.txt\\\" in the directory '..error_dir)\n" + " 'Error: '..tostring(err)..'\\n\\n'..\n" + " 'Details can be found in \\\"'..error_path..'\\\"')\n" " os.exit(1)\n" "end)\n" "return core and core.restart_request\n";