Why doesn't \verb work within ...?

The LaTeX verbatim commands work by changing category codes. Knuth says of this sort of thing "Some care is needed to get the timing right...", since once the category code has been assigned to a character, it doesn't change. So \verb has to assume that it is getting the first look at its parameter text; if it isn't, TeX has already assigned category codes so that \verb doesn't have a chance. For example:

\verb+\error+
will work (typesetting '\error'), but
\newcommand{\unbrace}[1]{#1}
\unbrace{\verb+\error+}
will not (it will attempt to execute \error). Other errors one may encounter are '\verb ended by end of line', or even '\verb illegal in command argument'.

This is why the LaTeX book insists that verbatim commands must not appear in the argument of any other command; they aren't just fragile, they're quite unusable in any command parameter, regardless of \protection. (The \verb command tries hard to detect if you're misusing it; unfortunately, it can't always do so, and the error message is therefore not a reliable indication of problems.)

The first question to ask yourself is: "is \verb actually necessary?".

Otherwise, there are three partial solutions to the problem.

Documentation of both url and verbdef is in the package files.
fancyvrb.sty
macros/latex/contrib/fancyvrb (zip, browse)
memoir.cls
macros/latex/contrib/memoir (zip, browse)
url.sty
macros/latex/contrib/misc/url.sty
verbdef.sty
macros/latex/contrib/misc/verbdef.sty

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=verbwithin