Software /
code /
verse
Changeset
422:ff59e4a1a600
libs.hashes: Better error message when method not available
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 27 Jun 2018 19:18:06 +0100 |
parents | 421:f35cfdff31b6 |
children | 423:e98cef597393 |
files | libs/hashes.lua |
diffstat | 1 files changed, 3 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/libs/hashes.lua Wed Jun 27 19:17:51 2018 +0100 +++ b/libs/hashes.lua Wed Jun 27 19:18:06 2018 +0100 @@ -1,22 +1,9 @@ -local function not_available() - error("not available", 2); +local function not_available(_, method_name) + error("Hash method "..method_name.." not available", 2); end -local _M = { - md5 = not_available; - hmac_md5 = not_available; - - sha1 = not_available; - hmac_sha1 = not_available; - scram_Hi_sha1 = not_available; - - sha256 = not_available; - hmac_sha256 = not_available; - - sha512 = not_available; - hmac_sha512 = not_available; -}; +local _M = setmetatable({}, { __index = not_available }); local function with(mod, f) local ok, pkg = pcall(require, mod);