js: Error handling for browser errors