R error handling and JSON javascript changes