slightly better handling of template exceptions