catch errors in template compile