lua-users home
lua-l archive

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


On 7 August 2018 at 16:05, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> Inside that 'if', write a message on io.stderr and return false.

Please don't!
This will manifest as e.g. a user reporting an error about trying to
index 'false'.
When they try and run code such as:

tls = require "org.conman.nfl.tls"
function dothething()
   tls.handshake(mysocket)
end
-- at some point later in response to user input:
    dothething()

It's better to fail fast and keep the error message close to the cause!


But also, writing to stderr from a library is an antipattern: please
never do this.
I might e.g. just be checking to see if your module is available and do:
pcall(require, "yourmodule")
I don't want output appearing in the user's terminal when I do that!