From d57db951aa8b67e413cdd4a59d7d3c6fc06eafd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Mon, 26 Feb 2024 23:53:32 +0100 Subject: Plugin load errors should not be fatal --- hex.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hex.c b/hex.c index a42459e..33aaeb8 100644 --- a/hex.c +++ b/hex.c @@ -1,7 +1,7 @@ /* * hex -- hex viewer * - * Copyright (c) 2016 - 2023, Přemysl Eric Janouch + * Copyright (c) 2016 - 2024, Přemysl Eric Janouch * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted. @@ -1205,6 +1205,8 @@ app_lua_load_plugins (const char *plugin_dir) return; } + lua_pushcfunction (g.L, app_lua_error_handler); + struct dirent *iter; while ((errno = 0, iter = readdir (dir))) { @@ -1213,16 +1215,19 @@ app_lua_load_plugins (const char *plugin_dir) continue; char *path = xstrdup_printf ("%s/%s", plugin_dir, iter->d_name); - lua_pushcfunction (g.L, app_lua_error_handler); if (luaL_loadfile (g.L, path) || lua_pcall (g.L, 0, 0, -2)) - exit_fatal ("Lua: %s", lua_tostring (g.L, -1)); - lua_pop (g.L, 1); + { + print_error ("%s: %s", path, lua_tostring (g.L, -1)); + lua_pop (g.L, 1); + } free (path); } if (errno) exit_fatal ("readdir: %s", strerror (errno)); closedir (dir); + + lua_pop (g.L, 1); } static void -- cgit v1.2.3