From c5837a5e38f2324ce7960840b609c290337ff160 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 2 May 2013 22:15:35 +0200 Subject: add warning if ``get_user_whatsit_name`` is called with unknown id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit another of Stephan Hennig’s suggestions --- luatexbase-attr.dtx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/luatexbase-attr.dtx b/luatexbase-attr.dtx index 54c26f7..60ca026 100644 --- a/luatexbase-attr.dtx +++ b/luatexbase-attr.dtx @@ -560,6 +560,9 @@ luatexbase.get_user_whatsit_id = get_user_whatsit_id % whatsit in question. First return value is the whatsit name, the second % the package identifier it was registered with. % +% We issue a warning and return empty strings in case the asked whatsit is +% unregistered. +% % \begin{macrocode} --- int | node -> (string, string) local get_user_whatsit_name = function (asked) @@ -569,7 +572,12 @@ local get_user_whatsit_name = function (asked) else --- node id = asked.user_id end - return tableunpack(whatsit_ids[id]) + local metadata = whatsit_ids[id] + if not metadata then -- unknown + warning("whatsit id %d unregistered; inconsistencies may arise", id) + return "", "" + end + return tableunpack(metadata) end luatexbase.get_user_whatsit_name = get_user_whatsit_name % \end{macrocode} -- cgit v1.2.3