Add more error checking to bridge.js
Add more error checking to bridge.js