updated app.js with a throw in case of non error