Update index.js

Issue with scope and error handling.
1 file changed