Added exception handling for Javascript syntax errors