CR changes: added error handling once a loadTemplate() fails
jsbeautify