Using LuaLaTeX in texlive2017, but I assume that this would apply generally.
Question: Is it possible to set a custom error message, that will be shown when a bad value is used as the argument to a length? The custom message would be defined as a string, which can be changed at various places in the document.
The usual error message is ``Missing number, treated as zero''. In my case, using a custom document class, I want to be able to guide the user to a specific place in the documentation. MWE:
\documentclass{article}
\newlength\mylength
\def\notalengthvalue{Hello!}
\def\isalengthvalue{20.6pt}
\begin{document}
\def\myerrmsg{Read documentation section 1.2.3.}
\setlength\mylength{\notalengthvalue} % error message is \myerrmsg
\def\myerrmsg{Read documentation section 3.7.2.}
\setlength\mylength{\notalengthvalue} % error message is \myerrmsg
\setlength\mylength{\isalengthvalue} % no error
\end{document}
If TeX had a Try/Catch routine, that would be easy. Lacking Try/Catch, is there another way to do it? That is, one that does not involve brute force pre-parsing of the argument for all possible strings that might be a length.
\setlength
to do that may well be incompatible with all sorts of things, setlength is used in a lot of places... – David Carlisle Jan 7 '18 at 23:19\setlength
. Rather, I thought that the error message might be contained in a command string such as\@err@when@bad@length@foo
that could be renewed. – user139954 Jan 7 '18 at 23:45