lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I would like to be able to test for the existence of any random package name by using the following idiom:

local aStatus, anError = pcall( require( aName ) )

However, this doesn't seem to behave as expected as the error is still unceremoniously raised and the lua interpreter promptly exits without further ado:

lua: ./LUBundle.lua:139: package `asdfasdfasd' not found
  cpath: ./?.so;/usr/local/lib/lua/5.1/?.so;./Library/Modules/?.so
path: ./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/ init.lua;./Library/Lua/?.lua
stack traceback:
        [C]: in function `require'
        ./LUBundle.lua:139: in function `bundleWithName'
        ./LUClass.lua:137: in function `classWithName'
        Example.lua:300: in main chunk
        [C]: ?

What would be the proper way to "safely" call require() without running a remake of "Chronicle of a Death Foretold"?

For the record, I'm using lua-5.1-work4.

Thanks! :)


PA, Onnay Equitursay