Update rest.js

Add in some error handling