Added Exception Handling for JavaScript