Let's say if I have...
\documentclass{article}
\errorcontextlines=10000
\def\c{1 \errorerror 2}
\def\b{3 \c 4}
\def\a{5 \b 6}
7 \a 8
I can
see the traceback on the console...
! Undefined control sequence. \c ->1 \errorerror 2 <argument> 3 \c 4 \b #1->7 #1 8 \a ->5 \b {3 \c 4} 6 l.13 7 \a 8run some code when there's error (
show_error_hookcallback)...access the string content of the error message
status.lasterrorcontext,status.lasterrormessageget the following tokens with repeated calls to
token.get_next()
However can I do the following:
- get the csname of the undefined token (programmatically)? Parsing the error message is not reliable.
- get the surrounding content (e.g. "before is
5 3 1")? - get the actual macros in the traceback (a, b, c in this case) and where in the definition they're currently at?
For context, sometimes the error message doesn't display nicely on the terminal (which is limited to text output so e.g. cannot distinguish active space from normal space / a small number of columns ), so I want to get the tokens and format it to something nicer.
status.lasterrorcontext? – David Carlisle Mar 28 '22 at 20:11\errorerroritself) – user202729 Mar 28 '22 at 20:24\overis the only exception). – Henri Menke Mar 31 '22 at 01:38