[Tex/LaTex] How to throw a custom error from \newcommand

macros

I'd like to write a command that checks the given arguments and throws an error if they are not in a range.

I'm imagining this would look something like this:

\usepackage{xifthen}

\newcommand{\wb}[2][]{\ifthenelse{{#2} > 0 \AND {#2} < 7}
    {\includegraphics[{#1}]{wong-baker/{#2}.eps}}}
    {%throw error here}
}

How can I check parameters in newcommand?

Best Answer

\PackageError{mypackage}{dont do that}{extra help}

see section 4.9 of texdoc clsguide

Related Question