Change js dependency to gem and clean up error handling