handle errors on client side