You can't use verbatim material inside another macros argument. The already mentioned cprotect
package works around that, but I would call it overkill using it here. Simply use a font declaration inside a group instead of a font macro, i.e. {\itshape text \verb+$%^+ text}
instead of \textit{text \verb+$%^+ text}
.
Applied to your code example:
\begin{frame}[fragile]{OCP en Exceptions}
``If you throw a checked exception from a method in your code and the
\verb!catch! is three levels above, {\itshape you must declare that
exception in the signature of each method between you and
the \verb!catch!}''
\end{frame}
Also using verbatim only to get the font effect is a misuse. Simply use tt
font directly! For often used real verbatim material I would recommend to define them as macros using \verbdef
of the verbdef
package. (There is also \Verbdef
of my newverbs
package if you need it in an expandable form, but normally this is not the case.)