This is a follow up to my question in this thread, in response to which @samcarter showed me how to combine <+-> with fragile. In the example below, I've tried to further automate his code by creating a fragileFrame environment which includes both of the above features. (Obviously, in this MWE it doesn't gain me much, but in my actual code, my beamer frames contain a lot of customization, which I don't want to have rewrite every time. However the environment construction throws an error. To verify that it really is the fragile option that's causing the error, I've created a normalFrame environment that is identical except for the fragile option, and compiles without error. Is there a way to get around this?
\documentclass{beamer}
\usepackage[framed]{matlab-prettifier}
\lstnewenvironment{myMPcolor}{%
\lstset{basicstyle=\color{red}}
}{}
\newenvironment{fragileFrame}[1]{%
\beamerdefaultoverlayspecification{<+->}
\begin{frame}[fragile]{#1}
}{\end{frame}}
\newenvironment{normalFrame}[1]{%
\beamerdefaultoverlayspecification{<+->}
\begin{frame}{#1}
}{\end{frame}}
\begin{document}
\begin{normalFrame}{Title}
\begin{itemize}
\item first point
\begin{itemize}
\item subpoint
\end{itemize}
\end{itemize}
\end{normalFrame}
\begin{fragileFrame}{Title}
\begin{itemize}
\item first point
\begin{itemize}
\item subpoint
\end{itemize}
\end{itemize}
\begin{myMPcolor}
This is a matlab command
\end{myMPcolor}
\end{fragileFrame}
\end{document}