Expansion of commands in errmessage

The document clsguide.pdf, in section 4.9 mentions \space, which is not (that is backslash followed by a space).

\newcommand{\foo}{FOO}
   \PackageError{ethel}{%
      Your hovercraft is full of eels,\MessageBreak
      and \protect\foo\space is \foo
   }{%
      Oh dear! Something's gone wrong.\MessageBreak
      \space \space Try typing \space <return>
      \space to proceed, ignoring \protect\foo.
}

Don't confuse \space with ; the former expands to a space, the second one is unexpandable; you find, in the LaTeX kernel,

\def\space{ }

Not quite an answer to the question, but related enough to warrant writing it. LaTeX3 provides ways to format nicely messages. In particular, within the command \iow_wrap:nnnN (and hence within all messages), is defined to expand to a space (just like \space). The list of available formatting commands is currently

  • expands to a space
  • \{ expands to a {
  • \} expands to a }
  • \# expands to a #
  • \% expands to a %
  • \~ expands to a ~
  • \\ goes to the next line
  • \iow_indent:n takes one argument and indents it by four spaces.

Example (well, I should probably have made \rescale do something rather than always throwing an error...).

\documentclass{article}
\usepackage{expl3, xparse}
\ExplSyntaxOn
\msg_new:nnnn { mypkg } { percentage-too-high }
  { The~fuction~\token_to_str:N\rescale\ cannot~scale~more~than~1000\% ! }
  {
    You~asked~to~rescale~the~picture\\\\
    \iow_indent:n {#1} \\ \\
    by~#2\%,~but~this~is~impossible.
  }
\NewDocumentCommand{\rescale}{mm}
  { \msg_error:nnnn { mypkg } { percentage-too-high } {#1} {#2} }
\ExplSyntaxOff
\begin{document}
  \rescale{foobar}{3250}
\end{document}

What do you think \edef\temp{My \pet\space is sick} gets expanded to?

\documentclass{article}
\def\pet{dog}
\begin{document}
  \edef\temp{My \pet\ is {sick}}
  \meaning\temp
  \show\temp
\end{document}
\temp=macro:->My dog\ is {sick}.