# HG changeset patch # User Matthew Wild # Date 1530123486 -3600 # Node ID ff59e4a1a600ea6d5100e364878a069d6a7d1664 # Parent f35cfdff31b6d8031ef2a323c1ea28ffd9df3ded libs.hashes: Better error message when method not available diff -r f35cfdff31b6 -r ff59e4a1a600 libs/hashes.lua --- 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);