@@ -40,12 +40,17 @@ local scroller = {}
4040
4141-- {{{ Helper functions
4242-- {{{ Determine operating system
43+ local kernel_name
4344function helpers .getos ()
45+ if kernel_name ~= nil then
46+ return kernel_name
47+ end
48+
4449 local f = io.popen (" uname -s" )
45- local uname = f :read (" *line" )
50+ kernel_name = string.lower ( f :read (" *line" ) )
4651 f :close ()
4752
48- return string.lower ( uname )
53+ return kernel_name
4954end
5055-- }}}
5156
@@ -63,17 +68,25 @@ function helpers.wrequire(table, key)
6368 }
6469
6570 local os = ostable [helpers .getos ()]
66- assert (os , " Vicious: platform not supported. " )
71+ assert (os , " Vicious: platform not supported: " .. helpers . getos () )
6772
6873 for i = 1 , # os do
69- local status , value = pcall (require , table ._NAME .. " ." .. key .. " _" .. os [i ])
74+ local name = table ._NAME .. " ." .. key .. " _" .. os [i ]
75+ local status , value = pcall (require , name )
7076 if status then
7177 ret = value
7278 break
7379 end
80+ not_found_msg = " module '" .. name .. " ' not found"
81+
82+ -- ugly but there is afaik no other way to check if a module exists
83+ if value :sub (1 , # not_found_msg ) ~= not_found_msg then
84+ -- module found, but different issue -> let's raise the real error
85+ require (name )
86+ end
7487 end
7588
76- assert (ret , " Vicious: widget " .. table ._NAME .. " ." .. key .. " not available for current platform. " )
89+ assert (ret , " Vicious: widget " .. table ._NAME .. " ." .. key .. " not available for current platform or does not exits " )
7790
7891 return ret
7992end
0 commit comments