Update index.js

correctly handle rendering errors