Better handling of error from nodejs server. Still not the best way of doing it though