Fixing broken exception handling from mako.