diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2016-04-26 23:13:09 +0200 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2016-04-26 23:17:54 +0200 |
commit | ae9a8c83c83a4ad5f6fe0288d801512421e895de (patch) | |
tree | 75cd136ae304698c4608220996299f4991f34159 | |
parent | a62867edb4dc4b5d46fe2b8c34fa4f6dc7fddc5c (diff) | |
download | luaotfload-ae9a8c83c83a4ad5f6fe0288d801512421e895de.tar.gz |
[main] handle module load failure
Forward the errors received from require() in a readable manner and exit
on the spot.
-rw-r--r-- | src/luaotfload-main.lua | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 51a0657..9e8d088 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -111,9 +111,33 @@ local make_loader = function (prefix) return function (name) local t_0 = osgettimeofday () local modname = make_loader_name (prefix, name) - local data = require (modname) + --- We don’t want the stack info from inside, so just pcall(). + local ok, data = pcall (require, modname) local t_end = osgettimeofday () timing_info.t_load [name] = t_end - t_0 + if not ok then + io.write "\n" + local msg = luaotfload.log and luaotfload.log.report or print + msg ("both", 0, "load", "FATAL ERROR") + msg ("both", 0, "load", " × Failed to load module %q.", + tostring (modname)) + local lines = string.split (data, "\n\t") + if not lines then + msg ("both", 0, "load", " × Error message: %q", data) + else + msg ("both", 0, "load", " × Error message:") + for i = 1, #lines do + msg ("both", 0, "load", " × %q.", lines [i]) + end + end + io.write "\n\n" + local debug = debug + if debug then + io.write (debug.traceback()) + io.write "\n\n" + end + os.exit(-1) + end return data end end |