Adding error handleing, both serverside and client side