[Tex/LaTex] Unhelpful, misleading errors in amsmath environments

amsmatherrorskile

With the simple equation environment;

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
 a \foo b
\end{equation}
\end{document}

you can see a helpful error message, which editors like Kile understands;

! Undefined control sequence.
l.5  a \foo
            b

Making it report 5: Undefined control sequence a \foo

But if you do the same in an amsmath environment, such as the popular align

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
 a \foo b
\end{align}
\end{document}

you get the unhelpful error (and it comes up twice);

! Undefined control sequence.
<argument>  a \foo 
                   b 
l.6 \end{align}

which makes Kile report; 6: Undefined control sequence \end{align}.

Checking the log is tedious and ultimately unrewarding, because not even in there can I find the actual line which contained the undefined control sequence.
Can this awful behavior be helped in any way?

Best Answer

Simple answer: no. The align environment works very differently from equation: all of the material has to be read before any typesetting. (In that sense, it's similar to the beamer class frame environment, which people also ask similar questions about.) The material to be aligned has to be read before it is typeset to allow measurement, so it's not an option to simply 'drop' this.