[templates] added error handling.