[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How can a module intentionally fail to load?
- From: Sean Conner <sean@...>
- Date: Tue, 7 Aug 2018 00:19:48 -0400
It was thus said that the Great nobody once stated:
> On 2018-08-07 04:32, Sean Conner wrote:>
> > -----[ my-tls.lua / loaded as a module ]----
> >
> > local tls = require "org.conman.tls"
> >
> > if tls.LIBRESSL_VERSION < 0x2050000f then
> > ??? there's no point in continuing with loading
> > ??? this module, because libtls will not let us
> > ??? control the socket.
> > end
> >
> > How to I abort the module? There's nothing I can find in the
> >documentation to deal with this, unless I'm missing something.
>
> Does just throwing an error or assert()ing the test work?
It kind of works. I get:
> tls = require "org.conman.nfl.tls"
/usr/local/share/lua/5.1/org/conman/nfl/tls.lua:41: too old a version of TLS
stack traceback:
[C]: in function 'assert'
/usr/local/share/lua/5.1/org/conman/nfl/tls.lua:41: in main chunk
[C]: in function 'require'
stdin:1: in main chunk
[C]: ?
>
But ...
> print(package.loaded['org.conman.nfl.tls'])
userdata: 0x8064634
>
I think the userdata is the .so file (because each userdata in the TLS
module has a __tostring() method assigned to it), which is an unexpected
result.
I suppose it's good enough.
By the way, when it works,
> tls = require "org.conman.nfl.tls"
> print(package.loaded['org.conman.nfl.tls'])
table: 0x843fc18
>
-spc