Update main.js

Added improved error catching.