New method to handle exceptions for templating