catch exception within template